lichess-org / api

Lichess API documentation and examples
https://lichess.org/api
GNU Affero General Public License v3.0
414 stars 140 forks source link

Rate limiting for challenge creation is not clearly documented #264

Open th0masb opened 1 year ago

th0masb commented 1 year ago

Hi, I'm basically trying to get my bot to play as many games as the rate limiting allows. All I've seen in the docs is:

All requests are rate limited using various strategies, to ensure the API remains responsive for everyone. Only make one request at a time. If you receive an HTTP response with a 429 status, please wait a full minute before resuming API usage.

So when I encounter a 429 for challenge creation I backoff for 2 mins, but then I still get 429 responses for hours afterwards when making a request at 2 min intervals. The docs indicate I'm backing off for a sufficient amount of time but clearly I'm not. What duration is being used to measure the request rate?

Worth noting I'm continuing to have the event stream held open in parallel while making challenges, would this be causing continuous 429 responses?

benediktwerner commented 1 year ago

The amount of challenges is limited per day. In general, it's also a good idea to increase the backoff duration on repeated 429s.

th0masb commented 1 year ago

Thanks, it would be good to put some more specifics about rate limits on the docs for the various endpoints, the max number of request and duration. Appreciate it might be a lot of effort though. Where are the limits defined in the repo?

benediktwerner commented 1 year ago

It's not centralized. Though most of the time, it's in the controller defining the endpoint.