SDKs overview

The Trello API provides developers with programmatic access to Trello's features, enabling automation, custom integrations, and extensions. While the API is RESTful and can be consumed via standard HTTP requests, Software Development Kits (SDKs) and client libraries simplify this process. These libraries typically handle aspects such as request formatting, response parsing, and authentication, allowing developers to focus on application logic rather than low-level API interactions.

SDKs for the Trello API exist in both official and community-contributed forms. Official SDKs are typically maintained by Atlassian, the owner of Trello, and offer direct support and adherence to API changes. Community libraries, on the other hand, are developed and maintained by the broader developer community. They can offer broader language support or specialized functionalities, but their maintenance and compatibility with future API versions may vary.

The Trello API facilitates interactions with core Trello entities, including boards, lists, cards, members, and organizations. Developers can perform actions such as creating new cards, moving existing cards between lists, adding comments, and managing board members. Authentication for the Trello API is handled through OAuth 1.0 or by using API keys and tokens, with SDKs often providing helper functions for managing this process.

Official SDKs by language

Atlassian provides and supports official client libraries for the Trello API, though direct, actively maintained SDKs might be fewer in number compared to community efforts. The primary languages for which examples and potentially official or strongly supported client libraries exist include Node.js, Python, and Ruby. These libraries aim to streamline common tasks and reduce the boilerplate code required to interact with the API.

The following table outlines some key official or officially endorsed client libraries and their characteristics:

Language Package/Library Installation Command Maturity/Status
Node.js node-trello (community-driven but widely used in official examples) npm install node-trello Mature, community-maintained with active usage
Python py-trello (community-driven but widely used in official examples) pip install py-trello Mature, community-maintained with active usage
Ruby ruby-trello (community-driven but widely used in official examples) gem install ruby-trello Mature, community-maintained with active usage

While some of these libraries are community-driven, they are frequently referenced in official Trello API documentation and examples, indicating a level of de-facto endorsement due to their reliability and widespread adoption. Developers should always refer to the official Trello API documentation for the most up-to-date recommendations and support information.

Installation

Installing Trello API client libraries typically involves using the respective package manager for your chosen programming language. The following provides general installation instructions for the commonly used client libraries in Node.js, Python, and Ruby.

Node.js (using npm)

For Node.js, the node-trello library is a popular choice. To install it, use npm:

npm install node-trello

After installation, you can require it in your Node.js application:

const Trello = require('node-trello');

Python (using pip)

For Python, py-trello is a widely used client library. Install it using pip:

pip install py-trello

Then, import it into your Python script:

from trello import TrelloClient

Ruby (using RubyGems)

Ruby developers often use the ruby-trello gem. Install it via RubyGems:

gem install ruby-trello

In your Ruby application, require the gem:

require 'trello'

Before making API calls, you will need your Trello API key and a user token. These can be obtained from your Trello developer account.

Quickstart example

This section provides a quickstart example using the py-trello library in Python to fetch a user's Trello boards. This demonstrates basic initialization and a simple API call.

from trello import TrelloClient
import os

# Replace with your actual API key and token
# It's recommended to use environment variables for sensitive data
API_KEY = os.environ.get('TRELLO_API_KEY', 'YOUR_API_KEY')
API_TOKEN = os.environ.get('TRELLO_API_TOKEN', 'YOUR_API_TOKEN')

# Initialize the Trello client
client = TrelloClient(api_key=API_KEY, token=API_TOKEN)

# Get all boards for the authenticated user
# The member 'me' refers to the authenticated user
# For more details on Trello members, consult the Trello API reference documentation.
# You can also use a specific member ID instead of 'me'.
buddy = client.get_member('me')

buddy_boards = buddy.get_boards()

print(f"Boards for {buddy.full_name}:")
for board in buddy_boards:
    print(f"- {board.name} (ID: {board.id})")

# Example: Get cards from the first board
if buddy_boards:
    first_board = buddy_boards[0]
    print(f"\nCards on '{first_board.name}':")
    cards = first_board.get_cards()
    if cards:
        for card in cards:
            print(f"  - {card.name} (ID: {card.id})")
    else:
        print("  No cards found on this board.")
else:
    print("No boards found for the authenticated user.")

To run this example:

  1. Ensure you have Python and py-trello installed.
  2. Obtain your Trello API Key and Token from the Trello developer portal.
  3. Replace 'YOUR_API_KEY' and 'YOUR_API_TOKEN' with your actual credentials, or set them as environment variables named TRELLO_API_KEY and TRELLO_API_TOKEN. Using environment variables is a security best practice for sensitive information.
  4. Execute the script. It will print the names and IDs of your Trello boards and the cards on the first board found.

This example demonstrates basic client initialization and fetching data. For more advanced operations like creating cards, moving lists, or managing webhooks, refer to the Trello API reference documentation.

Community libraries

Beyond the officially supported or commonly referenced client libraries, the Trello developer community has created various libraries and wrappers for other programming languages and frameworks. These community efforts often fill gaps in language support or provide specialized integrations. While not officially maintained by Atlassian, they can be valuable resources for developers working in specific environments.

When considering a community library, it is advisable to check the project's activity, recent updates, issue tracker, and community support to ensure it is well-maintained and compatible with the current Trello API version. Some examples of languages with known community support include:

  • PHP: Various PHP wrappers exist, often found on GitHub, enabling server-side integration with Trello.
  • Java: Community libraries facilitate Trello API interactions within Java applications, supporting enterprise-level integrations.
  • Go: Several Go client libraries are available for developers building high-performance services with Trello.
  • C#: .NET developers can find C# wrappers to integrate Trello into Windows applications or backend services.

Developers are encouraged to explore platforms like GitHub and package repositories (e.g., Packagist for PHP, Maven Central for Java) for the latest community contributions. Always review the source code and documentation of third-party libraries before integrating them into production systems.