norberteder / trello

Use the Trello API from Node
334 stars 250 forks source link
api javascript nodejs trello trello-api

Build Status

trello

A simple asynchronous client for Trello

This is a wrapper for some of the Trello HTTP API. Please feel free to add any other pieces you need! :)

Installation

npm install trello

Usage

Log in to Trello and visit trello.com/app-key to get a token and app key. These need to be supplied when you create the Trello object (see below).

Example

  var Trello = require("trello");
  var trello = new Trello("MY APPLICATION KEY", "MY USER TOKEN");

  trello.addCard('Clean car', 'Wax on, wax off', myListId,
      function (error, trelloCard) {
          if (error) {
              console.log('Could not add card:', error);
          }
          else {
              console.log('Added card:', trelloCard);
          }
      });

Callback or promise

API calls can either execute a callback or return a promise. To return a promise just omit the callback parameter.

  //Callback
  trello.getCardsOnList(listId, callback);

  //Promise
  var cardsPromise = trello.getCardsOnList(listId);
  cardsPromise.then((cards) => {
    //do stuff
  })

Requests to API endpoints, not supported by this lib yet

    // Get all registered tokens and webhooks
    // Url will look like: https://api.trello.com/1/members/me/tokens?webhooks=true&key=YOURKEY&token=YOURTOKEN
    trello.makeRequest('get', '/1/members/me/tokens', { webhooks: true })
      .then((res) => {
          console.log(res)
      });

Available functions

Add

Delete

Get

Update

Everything that is not available as a function can be requested by calling makeRequest.

History

0.13.0

0.12.0

0.11.0

0.10.0

0.9.1

0.9.0

0.8.0

0.7.0

0.6.0

0.5.1

0.5.0

0.4.1

0.4.0

0.3.0

0.2.0