Skip to content

Cards JavaScript

BL edited this page Dec 9, 2017 · 1 revision

Usage

export TRELLO_API_KEY=KEY
export TRELLO_OAUTH_TOKEN=TOKEN

Configuration

Set your Trello Api Key and Trello Auth Token.

var Trello = require('trello-node-api')(TRELLO_API_KEY, TRELLO_OAUTH_TOKEN);

Cards

Create Card

    var data = {
        name: 'CARD_NAME',
        desc: 'Card description',
        pos: 'top',
        idList: 'LIST_ID', //REQUIRED
        due: null,
        dueComplete: false,
        idMembers: ['MEMBER_ID', 'MEMBER_ID', 'MEMBER_ID'],
        idLabels: ['LABEL_ID', 'LABEL_ID', 'LABEL_ID'],
        urlSource: 'https://example.com',
        fileSource: 'file',
        idCardSource: 'CARD_ID',
        keepFromSource: 'attachments,checklists,comments,due,labels,members,stickers'
    };
    Trello.card.create(data).then(function (response) {
        console.log('response ', response);
    }).catch(function (error) {
        console.log('error', error);
    });

Search Card

    Trello.card.search('CARD_ID').then(function (response) {
        console.log('response ', response);
    }).catch(function (error) {
        console.log('error', error);
    });

Search Field Card

    Trello.card.searchField('CARD_ID', 'FIELD_NAME').then(function (response) {
        console.log('response ', response);
    }).catch(function (error) {
        console.log('error', error);
    });

Update card

    var id = 'CARD_ID'; // REQUIRED
    var data = {
       name: 'CARD_NAME_TEST',
       desc: 'Card description',
       closed: false,
       idMembers: 'MEMBER_ID,MEMBER_ID,MEMBER_ID',
       idAttachmentCover: null,
       idList: 'LIST_ID',
       idLabels: 'LABEL_ID, LABEL_ID, LABEL_ID',
       idBoard: false,
       pos: 'top',
       due: null,
       dueComplete: false,
       subscribed: false
    };
    Trello.card.update(id, data).then(function (response) {
        console.log('response ', response);
    }).catch(function (error) {
        console.log('error', error);
    });
Delete Card
    Trello.card.del('CARD_ID').then(function (response) {
        console.log('response ', response);
    }).catch(function (error) {
        console.log('error', error);
    });