API reference
Rate limits
When you pass a limit, wait the seconds in Retry-After and send the request again.
export async function fetchWithRetry(url: string, init: RequestInit, maxRetries = 3) {
for (let attempt = 0; ; attempt++) {
const res = await fetch(url, init);
if (res.status !== 429 || attempt === maxRetries) return res;
const seconds = Number(res.headers.get("Retry-After") ?? 1);
const jitter = Math.random() * 250;
await new Promise((resolve) => setTimeout(resolve, seconds * 1000 + jitter));
}
}Check the limits
Limits are the same on every plan. Batch parameters into one /v1/query request, and cache past days, to stay under them.
Read a 429
HTTP/1.1 429 Too Many Requests
Retry-After: 8
X-RateLimit-Limit: 120
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1735732810000{
"success": false,
"error": "Rate limit exceeded",
"code": "RATE_LIMITED",
"requestId": "req_abc123def456",
"limit": 120,
"remaining": 0,
"reset": 1735732810000,
"retryAfter": 8
}Only the 429 response is sure to carry these headers. If keys can't be checked for a moment, you get 503 with SERVICE_UNAVAILABLE and Retry-After: 5.
Related
How is this guide?