Guides
Rate limits
Each key may make 600 requests a minute (1,200 requests on Enterprise). Every answer says how many are left.
How many
- Free
- No API: calls are refused with
402 plan-feature. - Pro
- No API: calls are refused with
402 plan-feature. - Business
- 600 requests a minute, per key.
- Enterprise
- 1,200 requests a minute, per key.
Requests are counted per key in each calendar minute (the count starts again at the start of every minute), across every copy of the api. Each key has its own count, so two systems with their own keys do not slow each other down.
The headers
- X-RateLimit-Limit
- The key’s requests a minute.
- X-RateLimit-Remaining
- How many are left this minute.
- Retry-After
- On a
429: the seconds until the next minute starts, when the key may call again.
Over the limit
A request over the limit is refused with 429 rate-limited, and nothing is done:
HTTP/1.1 429 Too Many Requests
Content-Type: application/problem+json
Retry-After: 17
X-RateLimit-Limit: 600
X-RateLimit-Remaining: 0
{
"type": "https://gbalejo.com/problems/rate-limited",
"title": "Too many requests",
"status": 429,
"detail": "This key may make 600 requests a minute.",
"instance": "/api/v1/visits",
"traceId": "6f1c2e0a-8d4b-4a7e-9c3f-5e2b7d1a9c16"
}Wait for Retry-After and send it again:
async function gbalejo(path, init = {}) {
const url = `https://api.gbalejo.com/api/v1${path}`;
const headers = { ...init.headers, Authorization: `Bearer ${process.env.GBALEJO_API_KEY}` };
for (let attempt = 0; ; attempt++) {
const response = await fetch(url, { ...init, headers });
if (response.status !== 429 || attempt === 2) return response;
const seconds = Number(response.headers.get('Retry-After') ?? 1);
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
}
}One address has a limit too. However many keys it uses, one address may make 2,400 requests a minute; beyond that the answer is 429 too-many-requests, with Retry-After.