Trello Rate Limit
Asked by Yatish Madhav:

Hi all,

So I am using this wrapper (<https://github.com/cdaguerre/php-trello-api>) to automate Trello cards on an internal platform. One page lists actions and triggers that need to take place or Trello cards to be copied when the actions take place - mostly relating to staff on-boarding and departure ... On listing the page of actions and triggers, I get the following in the error log ...

`[2019-06-03 12:33:53] request.CRITICAL: Uncaught PHP Exception Trello\Exception\RuntimeException: "Rate limit exceeded" at /var/www/html/vendor/cdaguerre/php-trello-api/lib/Trello/HttpClient/HttpClient.php line 152 {"exception":"[object] (Trello\\Exception\\RuntimeException(code: 429): Rate limit exceeded at /var/www/html/vendor/cdaguerre/php-trello-api/lib/Trello/HttpClient/HttpClient.php:152, Trello\\Exception\\RuntimeException(code: 429): Rate limit exceeded at /var/www/html/vendor/cdaguerre/php-trello-api/lib/Trello/HttpClient/Listener/ErrorListener.php:62)"} []`

All that we do is a refresh of the page but the weird thing is that the list displays fine at times. But gives that error in the log at other times.

Any advice to debug all the calls that are happening?

Thank you in advance


Answers:
author: matt
body: Hi Yatish,

It sounds like you are running into Trello API rate limits. You can find a lot more detail about our rate limits here <https://developers.trello.com/docs/rate-limits> but in short a single token or application key is limited to making a certain number of requests in a time window. In the case of a single token which would be my initial guess for your case, that limit is generally 100 requests in a 10 second window.

In general the way to handle these kinds of errors is two-fold. We recommend throttling your requests so that you avoid exceeding the limit in the first place. We also recommend that if you do run into the limit, you can implement a retry system which can re-make the requests that failed after some back off (i.e. waiting 10 seconds).

comments: author: Yatish Madhav
body: Hi Matthew,

Thanks for the answer and tips.

Yes, I am aware that it is due to the rate limit that is being hit. Just not sure how and why it is being hit, basically trying to get to the root of the rate limit :) ... I tried to create a webhook with the same token on the organization as the model Object to see the calls made to the API to monitor it. And I get no POST returns made to the webhook callback URL.

Is there another way to monitor or find out how and why the rate limit is being hit?

Side question - Can I create a webhook on the organization object level to see all activity done across all boards and members within the Team? If so, does that affect the rate limit too.

Thank you

Yatish


author: matt
body: If you can send us the API key that you are using for your requests to the Trello API in an email to platform \[at\] trello.com we can help take a look into what requests your app is making and why it is being rate limited. Setting up webhooks, and receiving events from webhooks that you setup shouldn't have any impact on your rate limits, but unfortunately at the moment you can't simply setup a webhook on an organization and get all the events across all board in the organization. Instead you'd have to setup a webhook per board in the team for that.

- Matt


Tags: rate