Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get all Actions for a Board using Trello's Rest API?

I want to get all the actions for a board, but Trello limits the results to 1000. I understand the correct way to deal with this is to paginate. I've tried both before and page as keywords:

Basic Call:

https://api.trello.com/1/board/[boardID]/
         ?key=[key]&token=[token]
         &actions=commentCard&actions_limit=1000

Alternatives:

Before:

https://api.trello.com/1/board/[boardID]/
         ?key=[key]&token=[token]
         &actions=commentCard&actions_limit=1000&
         before=[oldest_returned_action's_date]

Page:

https://api.trello.com/1/board/[boardID]/
         ?key=[key]&token=[token]
         &actions=commentCard&actions_limit=1000&
         page=[page_number]

The result never varies --- I always get back [limit] number of actions, and they're always the same no matter the call. I checked the dates in what was returned and they certainly don't respect the before parameter. I even tried lowering the limit to make sure I wasn't trying to return more than I possessed. The problem persists.

How can I correctly get all actions for a Trello board?

like image 609
Elliptica Avatar asked Aug 09 '18 23:08

Elliptica


People also ask

Is there an API for trello?

Trello provides a simple RESTful web API where each type of resource (e.g. a card, a board, or a member) has a URI that you can interact with. Notes: All API requests go to https://api.trello.com.

How do I access Trello API?

You can get your API key by logging into Trello and visiting https://trello.com/app-key . Be sure to read and agree to Trello Developer Terms of Service. Your API key will be clearly labeled at the top of that page. Your API key should be a 32 character string comprised of random alphanumeric characters.


1 Answers

Actions are in reverse chronological order (newest-to-oldest), so to page through the actions on a board, you would use something like:

curl "https://api.trello.com/1/boards/${BOARD_ID}/actions/?key=${TRELLO_API_KEY}&token=${TRELLO_TOKEN}&limit=1000"

then, from the last element of the array returned by the the above, select the date or id and pass that as the before parameter in the next call, e.g.:

curl "https://api.trello.com/1/boards/${BOARD_ID}/actions/?key=${TRELLO_API_KEY}&token=${TRELLO_TOKEN}&limit=1000&before=${DATE_OR_ID_OF_LAST_ACTION}"

and repeat, passing in either the id or date of the last action as the subsequent before parameter.

References:

  • Paging
  • Board Actions
  • Actions Nested Resource
like image 155
eddies Avatar answered Nov 03 '22 01:11

eddies