Getting List ID/ idList from Trello API

Published by Akhilesh on

Getting List ID / idList and board id /idBoard from Trello API

Following is a step by Step example of how to get the idList from Trello API and also add a Card to a particular list:

First of all we require a idCard or idBoard to begin, make sure you get them from the title bar in the browser,

it’s a gibberish text, example:

https://trello.com/b/90sqwPMK/work_board ( The b here represents the board id)

https://trello.com/c/tqojwC7/Work_Card       ( The c here represents the card id)

get one of those and save them, for use.

https://developers.trello.com/reference#cards-2

Trello API documentation displaying idList as a required field

Trello API documentation displaying idList as a required field

As you can see idList or List id of a particular Trello board is required field for API interaction.

TRELLO–> BOARD—–>LISTS—–>CARDS

                    (Board id) –>  (List id) –> (Card id)

Above is the Hierarchy, with unique id’s associated with each member at each step.

This this is how I did it,

METHOD-1

I used the POSTMAN app(Chrome Plugin) [Chrome Extension, Desktop App]

Free! Learn More

Our Onboarding App Google sheets

add-on which uses Trello to onboard employees – Download

and sent an url GET request to the page, parsed the incoming data as JSON, and I got all the data I would ever need, boardID, listId etc.

So from there on it was simple ctrl+f, and I got it.

URL used:

Before using the following URL, be sure that you have the cardId because this is the code for retrieving data from a trello card and uses a GET request for the same.

https://api.trello.com/1/cards/[card id]?attachments=false&attachment_fields=all&checklists=none&checklist_fields=all&sticker_fields=all&key=[“key-insert your key here”]&token=[“token-insert your token here”]

Postman App Example of filling a request

Postman App Example of filling a request

Postman App Example of receiving and rendering the result

Postman App Example of receiving and rendering the result



As you can see,

The 30th line contains idBoard,

The 32nd line contains idList, which we want!

A much clutter-free way to do it→

METHOD-2

I also wrote another NodeJS API to parse the data as JSON, and give any relevant details I ask for, It worked much better as there was no Clutter this time around.

Here is the code for the same:

******************************************************************************************************

//NodeJS script to retrieve relevant details from the Trello //Board api

//Make sure you have the cardId of atleast one card from //the list whoose id you want to know

var options = { method: ‘GET’,

 url: ‘https://api.trello.com/1/cards/snNbR6TF’,

 qs:

  { attachments: ‘false’,

attachment_fields: ‘all’,

checklists: ‘none’,

checklist_fields: ‘all’,

sticker_fields: ‘all’,

key: [Key],

token: [Token] } };

  request(options, function (error, response, body) {

    if (error) throw new Error(error);

    else{

//Parse the incoming body as JSON data as it is in a String     //Format!  

      var obj = JSON.parse(body);

//Mention here the parameter you want to retireve from the //Massive incoming body

             console.log(“idList : “+obj.idList);

}

});

******************************************************************************************************

OUTPUT:

Running result on Mac terminal NodeJs

Running result on Mac terminal NodeJs

Thank you for reading!

FAQ’s

  1. Where do I find my User Specific Token/Key?
  2. Where do I find the cardID, boardId etc.?

ANSWER:

It’s a challenge.

Hint: Use the internet.