Skip to content

MrRefactoring/trello.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

48 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

trello.js logo

trello.js

npm version npm downloads bundle size CI license

Type-safe Trello REST API client for Node.js and the browser.

English Β· Русский

Why trello.js

  • πŸ”’ Fully typed β€” every endpoint, parameter, and response. No any, no guessing.
  • βœ… Runtime validation powered by Zod 4 β€” drift between docs and reality is caught at the boundary.
  • 🌳 Tree-shakable β€” subpath exports per namespace (trello.js/boards, trello.js/cards, …) plus trello.js/models and trello.js/parameters. Pay only for what you import.
  • πŸ“¦ ESM-only, modern Node.js (β‰₯22), browser-ready via any bundler.
  • πŸ§ͺ Full API coverage β€” 17 namespaces, 250+ methods, auto-generated from the official Trello swagger.
  • ⚑ Built-in retry for 429 responses with exponential backoff.
  • πŸ“ One runtime dependency β€” zod.

Installation

Requires Node.js 22+ and an ESM project ("type": "module" or a bundler).

pnpm add trello.js
# or
npm install trello.js
# or
yarn add trello.js

Quick start

  1. Get your API key and token from Trello.
  2. Create a client and make your first call:
import { createTrelloClient } from 'trello.js';

const trello = createTrelloClient({
  apiKey: process.env.TRELLO_KEY!,
  apiToken: process.env.TRELLO_TOKEN!,
});

const board = await trello.boards.createBoard({
  name: 'My first board',
  desc: 'From trello.js with love',
});

console.log(board.url);

That's it.

Recipes

Boards

const board = await trello.boards.getBoard({ id: boardId });
const lists = await trello.boards.getBoardLists({ id: boardId });

await trello.boards.updateBoard({ id: boardId, closed: true });

Cards

const card = await trello.cards.createCard({
  idList: listId,
  name: 'Write release notes',
  pos: 'top',
});

await trello.cards.updateCard({ id: card.id, idList: targetListId });
await trello.cards.createCardComment({ id: card.id, text: 'Done.' });

Search

const result = await trello.search.search({
  query: 'release',
  modelTypes: 'cards,boards',
  cards_limit: 20,
});

result.cards?.forEach((c) => console.log(c.name));

Webhooks

const webhook = await trello.webhooks.createWebhook({
  idModel: boardId,
  callbackURL: 'https://my-app.example.com/trello/hook',
  description: 'Activity stream',
});

Your callbackURL must respond 200 to a HEAD request β€” Trello checks it at creation time.

Tree-shakable imports

For the smallest possible bundle, import the namespace functions directly:

import { createClient } from 'trello.js/core';
import { getBoard } from 'trello.js/boards';
import { createCard } from 'trello.js/cards';

const client = createClient({ apiKey, apiToken });

const board = await getBoard(client, { id });
const card = await createCard(client, { idList: board.idLists?.[0], name: 'Hi' });

Bundlers strip out unused namespaces. The 15+ namespaces you don't import never end up in your output.

TypeScript & schemas

Types flow from the methods automatically:

const board = await trello.boards.getBoard({ id });
//    ^? Board

Every model also has a runtime Zod schema. Import from the root or the dedicated subpath:

import { BoardSchema, type Board } from 'trello.js/models';

const board: Board = BoardSchema.parse(payload);

Need to bypass parsing entirely? Pass skipParsing: true when creating the client. schema.parse() is then skipped β€” no ZodError, no validation, and no schema transforms (date fields stay strings rather than Date objects). This trades runtime type-safety for speed and resilience against schema drift; leave it false (the default) unless you have a reason.

const trello = createTrelloClient({ apiKey, apiToken, skipParsing: true });

Error handling

Non-2xx responses throw Error('Request failed: <status> <statusText> - <body>'). Schema mismatches throw ZodError. Rate-limit 429s retry automatically (2 s, 4 s, 8 s).

try {
  await trello.boards.getBoard({ id: 'bad' });
} catch (err) {
  if (err instanceof Error && err.message.includes('404')) {
    // handle not-found
  }
}

See the error handling guide for details.

Documentation

πŸ“– Full documentation β€” guides, recipes, migration
πŸ“š API reference β€” every method, generated from source
πŸ‡·πŸ‡Ί Русская вСрсия

Compatibility

  • Node.js β‰₯ 22 (ESM-only)
  • TypeScript β‰₯ 6.0 recommended
  • Modern bundlers: Vite, webpack 5+, Rollup, esbuild

Migrating from v1?

See the v1 β†’ v2 migration guide. Headline changes: new TrelloClient β†’ createTrelloClient, key/token β†’ apiKey/apiToken, ESM-only, Node 22+.

Contributing

See CONTRIBUTING.md. Most of src/ is auto-generated from the Trello swagger β€” please don't hand-edit src/api/, src/models/, or src/parameters/.

License

MIT Β© Vladislav Tupikin

About

Type-safe Trello REST API client for TypeScript & JavaScript. ESM-only, tree-shakable, runtime-validated by Zod 4. Full coverage of boards, cards, lists, checklists, members, webhooks, organizations. Atlassian Trello SDK for Node.js 22+ and modern browsers.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors