Handle rate limits #504
bocops
started this conversation in
Architecture & Design
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Mastodon instances have rate limits defaulting to 300 requests per 5 minutes both per account and per IP: documentation
The currently closest limit to be hit by a client is returned in the response header of each request. In a recent test to retrieve a list and iterate over all its user accounts, these look like this:
As a library user, it would be nice to be aware of approaching limits somehow, to be able to throttle before a limit is reached and subsequent requests fail. Questions:
limit
andremaining
(allowed requests) as-is, but should probably convert thereset
timestamp into something more sensible, like "time remaining until reset". Note that, if we return the remaining time in seconds, a simple comparison between "requests remaining" and "seconds remaining" would suffice to see if our client is currently behaving well, because 300/5 requests/min boils down to an allowed average of 1 request/second.MastodonRequest.execute()
, but that already returns the requested data.Beta Was this translation helpful? Give feedback.
All reactions