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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With