Skip to main content

Async Trello API client for Python

Project description

Trellio - Async Trello API Client for Python

License: GPL v3 Python 3.9+

Trellio is a production-ready, asynchronous Python client for the Trello API, built on httpx and pydantic. Designed for use in long-running services like MCP servers, it provides retry with backoff, request timeouts, structured logging, and full CRUD coverage across 10 Trello resource types.

Features

Infrastructure

  • Async I/O -- built on httpx.AsyncClient, non-blocking
  • Retry with exponential backoff -- automatic retry on 429/5xx, respects Retry-After header, configurable max_retries, initial_delay, backoff_factor
  • Request timeout -- configurable per-client, raises TrelloAPIError on timeout
  • Pagination -- list_boards(limit, since) for single pages, list_all_boards(page_size) async generator for auto-pagination
  • Structured logging -- trellio logger with DEBUG (every request), WARNING (retries), ERROR (failures)
  • Typed exceptions -- TrelloAPIError(status_code, message) for all API errors
  • Pydantic models -- type-safe response objects with alias support for Trello's camelCase API

Resources (38 client methods)

Resource Methods
Auth get_me
Boards list_boards, list_all_boards, create_board, get_board, update_board, delete_board
Lists list_lists, create_list
Cards list_cards, create_card, get_card, update_card, delete_card
Labels list_board_labels, create_label, update_label, delete_label
Checklists list_card_checklists, create_checklist, get_checklist, delete_checklist, create_check_item, update_check_item, delete_check_item
Comments add_comment, list_comments, update_comment, delete_comment
Members list_board_members, get_member
Attachments list_attachments, create_attachment, delete_attachment
Webhooks create_webhook, list_webhooks, get_webhook, update_webhook, delete_webhook
Search search

Models

TrelloMember, TrelloBoard, TrelloList, TrelloCard, TrelloLabel, TrelloChecklist, TrelloCheckItem, TrelloComment, TrelloAttachment, TrelloWebhook, TrelloSearchResult

Quick Start

import asyncio
from trellio import TrellioClient

async def main():
    async with TrellioClient(
        api_key="your_key",
        token="your_token",
        max_retries=3,
        timeout=30.0,
    ) as client:
        boards = await client.list_boards()
        for board in boards:
            print(board.name)

        results = await client.search("project")
        for card in results.cards:
            print(card.name)

asyncio.run(main())

MCP Server Usage

from trellio import TrellioClient, TrelloAPIError

client = TrellioClient(
    api_key=os.environ["TRELLO_API_KEY"],
    token=os.environ["TRELLO_TOKEN"],
    max_retries=3,
    initial_delay=1.0,
    timeout=30.0,
)

# Use in MCP tool handlers:
async def handle_create_card(list_id: str, name: str):
    try:
        card = await client.create_card(list_id, name)
        return {"id": card.id, "name": card.name}
    except TrelloAPIError as e:
        return {"error": e.message, "status": e.status_code}

Philosophy: BDD & Single Source of Truth

This project follows strict Behavior-Driven Development (BDD) where Gherkin feature files are the Single Source of Truth for business logic. All implementation is derivative of the specifications.

Test Coverage

The BDD suite covers 16 features, 117 scenarios, 826 steps:

Feature Scenarios
Authentication 6
Boards 11
Cards 13
Lists 6
Labels 9
Checklists 13
Comments 9
Members 4
Attachments 7
Webhooks 13
Retry 7
Pagination 4
Connection 2
Timeout 2
Search 4
Logging 3
Total 117

Development Setup

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt -r requirements-dev.txt

# Run BDD suite
PYTHONPATH=src python -m behave

# Run mock validation
PYTHONPATH=src pytest tests/validation/

Quick Start with Make

For a fresh checkout, the simplest path is:

make test

This will:

  • create .venv if it does not exist
  • install dependencies if they are not available yet
  • run the validation tests with pytest
  • run the BDD suite with behave

You can also use:

make
make deps
make test-pytest
make test-behave

Architecture Decisions

ADR Title Status
001 Custom Mock Server and Validation Strategy Accepted
002 Mock Strategy: Custom Python vs. MockServer Accepted
003 Failure Path Enumeration Accepted

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trellio_client-1.2.0.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trellio_client-1.2.0-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file trellio_client-1.2.0.tar.gz.

File metadata

  • Download URL: trellio_client-1.2.0.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for trellio_client-1.2.0.tar.gz
Algorithm Hash digest
SHA256 d56e77ac05fd8166afa1f9979ac2e73a0839e0a529e55df4bb87302887b5e6aa
MD5 6b06c3e75635a35d11feb5ab10d48c8b
BLAKE2b-256 3deec0e7caf098830618d867b997bd36301a1b2ff8a0d4f296cee67905e332a2

See more details on using hashes here.

File details

Details for the file trellio_client-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: trellio_client-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for trellio_client-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d2eaa4df8c3b37690fcce5807c3ae784cbe4f13d87b91de19242a9af17e8cdb1
MD5 15dfae650fee3b1fb53dc8da4b37443b
BLAKE2b-256 7023801738c73328a567ffab959d1b1f5d965a79beaefaac410d4da0e9c176c9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page