There are 2 reasons a request can receive a 429 response. One for a per-second rate limit, and one for a per-day total limit.
But, the only way to potentially know which one you hit is to parse the message in the json. Could we possibly get an additional field added to the json error response maybe indicating which was hit?
{"code":429,
"limit": "daily", //other value could be "rate" for the per-second one
"message":"You have reached the maximum per-second rate limit for this API. Try again later."
}
In summary, it would be nice to âsubclassâ the 429 error if possible with a âwhich limitâ was hit.
Next request- mostly related. There is a âX-RateLimit-Remainingâ That only seems to be returned on 200 responses. It doesnât give us enough info to make proper rate limiting decisions. It would be nice if ALL responses contained something like these 3 examples:
429 response(per second exceeded)
"x-Ratelimit-category: heavy"
"X-RateLimit-daily-Remaining: 2000"
"x-ratelimit-daily-limit: 5000"
"x-ratelimit-rate-reset: 20" // Means the 429 you just got exceeded the rate limit and you should wait 20s
or
429 response(daily exceeded)
"x-Ratelimit-category: heavy"
"X-RateLimit-daily-Remaining: 0"
"x-ratelimit-daily-limit: 5000"
"x-Retry-After: date-time-limit-resets "
or
200 response
"x-Ratelimit-category: resource-intensive"
"X-RateLimit-daily-Remaining: 500"
"x-ratelimit-daily-limit: 1000"