39

Using Trello API:

  • I've been able to get all the cards that are assigned to a Trello user
  • I've been able to get all the boards that are assigned to an Organization

But I can't get any API call that returns all the lists that are in an Organization or User. Is there any function that allows that ?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Juan Fco. Sierra
  • 393
  • 1
  • 3
  • 4

6 Answers6

45

For the users who want the easiest way to access the id of a list :

Use the ".json" hack !

add ".json" at the end of your board URL to display the same output of the API query for that board, in your browser ! (no other tool needed, no hassle dealing with authentication).

For instance, if the URL of your board is :

https://trello.com/b/EI6aGV1d/blahblah

point your browser to

https://trello.com/b/EI6aGV1d/blahblah.json

And you will obtain something like

{
  "id": "5a69a1935e732f529ef0ad8e",
  "name": "blahblah",
  "desc": "",
  "descData": null,
  "closed": false,
  [...]
    "cards": [
      {
          "id": "5b2776eba95348dd45f6b745",
          "idMemberCreator": "58ef2cd98728a111e6fbd8d3",
          "data": {
            "list": {
              "name": "Bla blah blah blah blah",
              "id": "5a69a1b82f62a7af027d0378"
            },
            "board": {
            [...]

Where you can just search for the name of your list to easily find its id next to it.

tip: use a json viewer extension to make your browser display a nice json. Personnally I use https://github.com/tulios/json-viewer/tree/0.18.0 but I guess there are a lot of good alternatives out there.

enter image description here

edelans
  • 8,479
  • 4
  • 36
  • 45
37

I don't believe there is a method in the Trello API to do this, so you'll have to get a list of boards for a user or organization:

GET /1/members/[idMember or username]/boards

Which returns (truncated to show just the parts we care about):

[{
    "id": "4eea4ffc91e31d1746000046",
    "name": "Example Board",
    "desc": "This board is used in the API examples",
    ...
    "shortUrl": "https://trello.com/b/OXiBYZoj"
}, {
    "id": "4ee7e707e582acdec800051a",
    "name": "Public Board",
    "desc": "A board that everyone can see",
    ...
    "shortUrl": "https://trello.com/b/IwLRbh3F"
}]

Then get the lists for each board:

GET /1/boards/[board_id]/lists

Which returns (truncated to only show the list id and name:

[{
    "id": "4eea4ffc91e31d174600004a",
    "name": "To Do Soon",
    ...
}, {
    "id": "4eea4ffc91e31d174600004b",
    "name": "Doing",
    ...
}, {
    "id": "4eea4ffc91e31d174600004c",
    "name": "Done",
    ...
}]

And go through this response for each board to build a list of all the lists a user or organization has.

Avshalom
  • 8,657
  • 1
  • 25
  • 43
matthew-parlette
  • 1,234
  • 9
  • 5
  • 1
    As of now, there is a call to get a listing of all the boards on a trello organization. /organization/ORG_ID/boards?fields=name You can still pass each one of the IDs to fetch the lists of the boards – StanleyZheng Jun 22 '15 at 20:16
4

to get all your boards use

Trello.get("/members/me/boards")

worked for me using client.js

3

You can do it by calling

GET /1/organizations/[idOrg]/boards?lists=all

It is here: https://developers.trello.com/advanced-reference/organization#get-1-organizations-idorg-or-name-boards

Look at the arguments.

There are several filters and fields. You can customize it.

1

Here is a quick and dirty bash script using curl and jq to get any given Board's ID or List's Id:

key="<your-key>"
token="<your-token>"
trelloUsername="<you-trello-username>"
boardName="<board-name>"
listName="<list-name>"

boardID=$(curl -s --request GET --url "https://api.trello.com/1/members/$trelloUsername/boards?key=$key&token=$token" --header 'Accept: application/json' | jq -r ".[] | select(.name == \"$boardName\").id")
echo "boardID: ${boardID}"
listID=$(curl -s --request GET --url "https://api.trello.com/1/boards/$boardID/lists?key=$key&token=$token" | jq -r ".[] | select(.name == \"$listName\").id")
echo "listID: ${listID}"

Example output:

boardID: 5eab513c719d2d681bafce0e
listID: 5eab519e66dd4272gb720e22
Aaron N. Brock
  • 4,276
  • 2
  • 25
  • 43
0

To get all your Trello boards using the REST API via POSTMAN (in 2023):

curl --location --request GET 'https://api.trello.com/1/members/me/boards' \
--header 'Content-Type: application/json' \
--data '{
  "key": "{{ KEY }}",
  "token": "{{ TOKEN }}"
}'

Go to: Import > Raw Text paste the code and execute`

Kostas Minaidis
  • 4,681
  • 3
  • 17
  • 25