"Requested too many cards with action loads, please limit"


I’m trying to fetch the cards in a list, with the card comments, like this:

 curl "https://api.trello.com/1/lists/{list_id}/cards

For one particular list, I get back the an error:

  "message":"Requested too many cards with action loads, please limit",

Is there anything I can do, or am I obliged to get the list’s cards without comments, and then get the comments for each individual card? I’d have hoped the actions_limit might have helped, but it doesn’t.

Update 1:
I already use the batch mechanism to fetch multiple lists at a time … I’ll explore using it to get multiple cards at a time

Update 2:
I decided to fix this by adding a limit=500 when fetching the cards … this is for my Apple Watch app, and I can’t see people realistically scrolling through many cards on the watch. If/when I implement search this might become important again.

Do you have a canonical sync example anywhere, that makes full use of batch fetching, since, etc? Evernote have this and it is very handy, even if it just a textual description of a full initial sync, and then later incremental syncs.

This is the correct thing to do. Using the since and before parameters, you can continue to page through results to get everything. There is a brief mention of paging here: https://developers.trello.com/docs/api-introduction#section-paging

It is also worth mentioning that if you’re trying to do a sync (that is, grab the current state of a Trello board and then only get stuff that has changed) the cards_modifiedSince on the cards nested resource may be useful to you. It accepts a timestamp or an ID.

:sweat_smile:Not yet!

1 Like

I was struggling with too. Not having worked with Mongo DB and having missed the part of documentation about how mongo IDs contain creation time, I didn’t know what were the correct parameters to give to before for paging.

You can extract the date in JS using this

// https://stackoverflow.com/a/6453709/1412255
function mongoIDToDate(id) {
  const timestampHex = id.toString().substring(0,8)
  const timestamp = parseInt( timestampHex, 16 ) * 1000
  return new Date(timestamp);

and then the API end points seem to return the latest n results where n is the limit.

so you want to sort the returned results by timestamp (mongoIDToDate(card.id).getTime()) and get the oldest card, and call the API again with before param having the id of the oldest card.

Also the link to paging has slightly changed: https://developer.atlassian.com/cloud/trello/guides/rest-api/api-introduction/#paging