Developer docs contents
Rate limits
How the limit works, how to read it, and how to back off.
Each key has its own limit, in requests per second: 50 by default, raised on request up to 10,000. The limit is a bucket holding one second’s worth, so a key can burst to its full limit at once and then sustain it.
| Header | Meaning |
|---|---|
X-RateLimit-Limit | Your key’s limit per second. |
X-RateLimit-Remaining | Requests left in the bucket now. |
X-RateLimit-Reset | Seconds until the bucket is full again. |
Retry-After | On a 429 only: seconds to wait before retrying. |
Backing off
On 429, wait Retry-After seconds and send the same request again. On 503, nothing was queued: retry with exponential backoff and jitter.
async function send(url, init, attempt = 0) {
const response = await fetch(url, init);
if (response.status !== 429 && response.status !== 503) return response;
if (attempt >= 5) throw new Error(`Gave up after ${attempt} retries`);
const retryAfter = Number(response.headers.get("retry-after"));
const wait = retryAfter ? retryAfter * 1000 : Math.min(30_000, 500 * 2 ** attempt) * (0.5 + Math.random());
await new Promise((resolve) => setTimeout(resolve, wait));
return send(url, init, attempt + 1);
}