Back

Trello API Essential Guide

Jul 31, 20246 minute read

What type of API does Trello provide?

Trello uses a RESTful API (Representational State Transfer). This means that Trello's API follows the principles of REST, which is an architectural style for designing networked applications. A RESTful API allows clients to access and manipulate web resources via standard HTTP methods such as GET, POST, PUT, DELETE, etc.

REST APIs are stateless, meaning each request from client to server must contain all the information needed to understand and complete the request. The server should not store anything about the latest HTTP request the client made. Each request is treated independently.

Here's a brief overview of how you might interact with Trello's RESTful API:

Getting Information

To retrieve information from Trello, you would typically use a GET request. For example, to get details about a specific board, you could make a request like this:

GET https://api.trello.com/1/boards/{id}

Creating Information

To create new items, such as adding a new card to a list, you would use a POST request. Here's an example:

POST https://api.trello.com/1/cards

Updating Information

To update existing items, you would use a PUT request. For instance, to change the name of a card:

PUT https://api.trello.com/1/cards/{id}/name

Deleting Information

Finally, to delete items, you would use a DELETE request. To remove a card, for example:

DELETE https://api.trello.com/1/cards/{id}

Each of these operations requires proper authentication, typically handled through OAuth tokens, which allow your application to securely access Trello's API on behalf of a user.

For more detailed information, including how to authenticate and the full range of capabilities offered by Trello's API, refer to the official Trello Developer Documentation: Trello Developer Portal

RESTful APIs like Trello's are widely used due to their simplicity, scalability, and stateless nature, making them a good choice for web services that need to be easily accessible across the internet.

Does the Trello API have webhooks?

Yes, the Trello API supports webhooks. Webhooks allow developers to receive notifications when a model within Trello changes. These models can include members, cards, boards, or other entities that actions can apply to. When an event occurs involving the monitored model, a webhook is triggered, sending an HTTP POST request to a specified callback URL with details about the action and the updated model.

To use webhooks, you need to:

  1. Obtain a token through Trello's web client authorization process or OAuth.
  2. Provide a callbackURL parameter for Trello to send HTTP POST requests.
  3. Handle JSON payloads containing action details and updated model information.

Trello will disable webhooks that experience consecutive failures for 30 days without a successful event sending. Failures can occur due to issues like the callback endpoint not responding correctly or the webhook's token losing access to the monitored model.

Here's an example of creating a webhook using jQuery's $.post method:

$.post("https://api.trello.com/1/tokens/{APIToken}/webhooks/?key={APIKey}", { description: "My first webhook", callbackURL: "http://www.mywebsite.com/trelloCallback", idModel: "4d5ea62fd76aa1136000000c", // ID of the model to watch });

Replace {APIToken}, {APIKey}, callbackURL, and idModel with your specific values.

Rate Limits and other limitations

Direct Answer to the Question

The Trello API imposes several rate limits to prevent strain on its servers:

  • General Rate Limits: Each API key is limited to 300 requests per 10 seconds, and each token is limited to 100 requests per 10 seconds. Exceeding these limits will result in a 429 error response from Trello.
  • Special Route Limits: Requests to /1/members/ are further restricted to 100 requests per 900 seconds. This is part of Trello's measures to ensure responsible usage of resources that involve user account information.

Additional Information

  • Rate Limit Headers: Trello includes rate limit information in the headers of its API responses. These headers indicate the time interval of the limit (in milliseconds), the maximum number of requests allowed (max), and the remaining request count for the given interval (remaining). Monitoring these headers can help applications stay within the rate limits.

    Example of rate limit headers in a response:

    x-rate-limit-api-token-interval-ms: 10000
    x-rate-limit-api-token-max: 100
    x-rate-limit-api-token-remaining: 99
    x-rate-limit-api-key-interval-ms: 10000
    x-rate-limit-api-key-max: 300
    x-rate-limit-api-key-remaining: 299
    
  • Staying Under the Limit: To avoid hitting the rate limits, Trello suggests reducing polling frequency and considering the use of webhooks instead of continuous API polling. Webhooks allow for event-driven updates without the need for frequent API calls, thus helping to stay under the rate limits.

Best Practices

  1. Implement Rate Limiting Reduction Techniques: Throttle your requests to stay below the maximum allowed limits. Consider implementing delays between requests to further reduce the risk of hitting the rate limits.
  2. Use Middleware: Implement middleware to manage API calls efficiently. Middleware can cache responses, introduce delays, or batch requests to minimize the number of calls made to the API.
  3. Utilize Webhooks: Instead of polling the API for updates, use webhooks to receive real-time notifications of changes. This approach reduces the need for frequent API calls and helps in staying well within the rate limits.
  4. Monitor Rate Limit Headers: Pay attention to the rate limit headers in API responses to understand your current usage and adjust your request patterns accordingly to avoid exceeding the limits.

By understanding and adhering to these rate limits and employing best practices, developers can ensure smooth and uninterrupted access to the Trello API for their applications.

Latest API Version

The most recent version of the Trello API, as indicated by the provided sources, does not explicitly state a version number like v1, v2, etc., which is common in many APIs. Instead, the documentation and changelogs focus on features, deprecations, and changes within the existing API structure.

However, the API calls shown in the guides and examples use a base URL that starts with https://api.trello.com/1/, suggesting that the current version being referenced is version 1 of the Trello API. This is consistent across the examples given for making API calls, such as retrieving boards or members' information:

curl 'https://api.trello.com/1/boards/{idBoard}?key={yourKey}&token={yourToken}' curl 'https://api.trello.com/1/members/me/boards?key={yourKey}&token={yourToken}'

Given this information, it's reasonable to conclude that the most recent version of the Trello API being actively developed and maintained, as of the latest updates provided in July 2024, is still version 1. This version encompasses all the functionalities, endpoints, and features described in the Trello API documentation, including those related to boards, members, actions, and more.

It's important to note that while the major version might remain the same, the Trello API continuously evolves with new features, deprecations, and changes as indicated by the changelog entries. Developers should regularly consult the official Trello API documentation and changelog for the most up-to-date information and best practices for integrating with Trello.

How to get a Trello developer account and API Keys?

Step 1: Create a Trello Account or Login

Create a new Trello account or log in to your existing one at the Trello homepage.

Step 2: Generate an API Key

  1. Create a Trello Power-Up.
  2. Go to https://trello.com/power-ups/admin.
  3. Access your Power-Up and navigate to the "API Key" tab.
  4. Select "Generate a new API Key".

Step 3: Obtain an API Token

  1. On the same page as your API key, click the "Token" link.
  2. Grant access to your application, configuring permissions and duration as needed.
  3. Click "Allow".
  4. You'll be redirected to a page with your API token.

Step 4: Make Your First API Call

Use your API key and token to make requests to the Trello API. For example, to get all boards associated with your user:

curl 'https://api.trello.com/1/members/me/boards?key={yourKey}&token={yourToken}'

Replace {yourKey} and {yourToken} with your actual API key and token values.

What can you do with the Trello API?

The Trello API provides access to several data models that represent different aspects of Trello's functionality. Here's a breakdown of the primary data models you can interact with using the Trello API:

Boards

  • Description: Boards are central to Trello's organization structure. They can contain multiple lists and cards.
  • Interactions:
    • List, view, create, and edit boards.
    • Update board fields such as name and description.
    • Manage sub-resources like members and lists associated with a board.

Lists

  • Description: Lists reside within boards and typically represent stages or categories of tasks.
  • Interactions:
    • Create, read, update, and delete lists.
    • Move lists between boards.
    • Change list names and positions.

Cards

  • Description: Cards represent individual tasks or items within a list.
  • Interactions:
    • Create, read, update, and delete cards.
    • Add labels, members, checklists, and attachments to cards.
    • Move cards between lists and boards.

Members

  • Description: Members represent users who can be part of boards and organizations.
  • Interactions:
    • Add or remove members from boards.
    • Retrieve member information, including their boards and organizations.

Organizations (Workspaces)

  • Description: Organizations are collections of boards that can be shared among members.
  • Interactions:
    • Create, read, update, and delete organizations.
    • Manage organization members and their permissions.

Checklists

  • Description: Checklists are sub-components of cards, allowing for task subdivision.
  • Interactions:
    • Add, remove, and update checklists within cards.
    • Mark checklist items as completed or incomplete.

Labels

  • Description: Labels are used to categorize cards across boards.
  • Interactions:
    • Create, read, update, and delete labels.
    • Assign labels to cards.

Actions

  • Description: Actions represent activities performed within Trello, such as adding a card or commenting.
  • Interactions:
    • Retrieve actions related to boards, cards, and other entities.
    • Filter actions by date or type.
  • Description: The Trello API supports searching across various entities including actions, boards, cards, members, and organizations.
  • Interactions:
    • Perform searches with a query string to find matching entities.
    • Specify which fields to return in the search results.

Each of these data models plays a crucial role in the functionality of Trello, and the API provides extensive capabilities to interact with them programmatically. This allows developers to integrate Trello with other applications, automate workflows, and extend Trello's functionality to meet specific needs.