Overview
The Stable API enforces rate limits to ensure fair usage and protect service stability. Limits apply per caller across all endpoints.
Rate Limit Tiers
| Tier | Limit | Applies To |
|---|---|---|
| Anonymous | 60 requests / minute | Unauthenticated requests |
| Session | 200 requests / minute | Authenticated user across their sessions |
| API Token | 120 requests / minute per token | Each API token independently |
Unauthenticated requests are counted per IP address, signed-in sessions per user, and API tokens per token. Some endpoints have stricter limits of their own.
Response Headers
Responses include these headers:
| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests allowed in the current window |
X-RateLimit-Remaining | Requests remaining in the current window |
X-RateLimit-Reset | Seconds remaining until the window resets |
X-RateLimit-Scope | Which tier applies: anonymous, session, or api-token |
Example
HTTP/1.1 200 OK
X-RateLimit-Limit: 120
X-RateLimit-Remaining: 87
X-RateLimit-Reset: 45
X-RateLimit-Scope: api-token
In this example, the current window resets in 45 seconds, with 87 requests remaining out of 120.
When You Hit the Limit
When the limit is exceeded, the API returns:
HTTP/1.1 429 Too Many Requests
X-RateLimit-Scope: api-token
Retry-After: 45
Content-Type: application/json
{
"status": "429 Too Many Requests",
"message": "Too many requests",
"data": null,
"error": { "TooManyRequests": "Too many requests" },
"code": "too_many_requests"
}
The Retry-After header indicates how many seconds to wait before retrying.
Backoff Strategy
When you receive a 429, implement exponential backoff:
// Example for GET/read requests. Mutation retries need an idempotency contract.
async function fetchWithRetry(url: string, options: RequestInit, maxRetries = 3) {
for (let attempt = 0; attempt <= maxRetries; attempt++) {
const response = await fetch(url, options);
if (response.status !== 429) {
return response;
}
if (attempt === maxRetries) {
throw new Error('Rate limit exceeded after max retries');
}
// Use Retry-After header (seconds until window resets)
const retryAfter = response.headers.get('Retry-After');
const delay = retryAfter
? parseInt(retryAfter, 10) * 1000
: Math.min(1000 * Math.pow(2, attempt), 60000);
await new Promise((resolve) => setTimeout(resolve, delay));
}
}
Best Practices
- Monitor your usage via
X-RateLimit-Remainingheaders to avoid hitting limits - Implement backoff using the
Retry-Afterheader value (it's in seconds, not a timestamp) - Batch operations where possible instead of making many individual requests
- Cache responses for data that doesn't change frequently
- Use webhooks instead of polling to reduce API calls
- Keep retries bounded and preserve mutation keys only where the endpoint supports safe replay