Rate Limits
Learn about API rate limits and how to work with them.
Last updated
{
"error_type": "api_rate_limit_error",
"error_message": "Too Many Requests"
}// A simple exponential backoff implementation
retries = 0
max_retries = 5
loop:
try:
response = make_api_request()
break // Success, exit the loop
catch (error):
if error.status_code == 429 and retries < max_retries:
retries += 1
// Calculate wait time: 1s, 2s, 4s, etc. + random jitter
wait_time = (2 ** retries) * 1000 + random_integer(0, 1000)
wait(wait_time) // Wait in milliseconds
continue loop // Retry the request
else:
// If it's not a 429 error or we've run out of retries,
// re-throw the error to be handled by other logic.
throw error