Rate Limiting
Esta página aún no está disponible en tu idioma.
The Acme API enforces rate limits to ensure fair usage and system stability.
Rate Limit Tiers
Section titled “Rate Limit Tiers”| Plan | Requests/Minute | Requests/Day |
|---|---|---|
| Free | 60 | 1,000 |
| Pro | 600 | 50,000 |
| Enterprise | 6,000 | Unlimited |
Rate Limit Headers
Section titled “Rate Limit Headers”Every response includes rate limit information:
X-RateLimit-Limit: 600X-RateLimit-Remaining: 595X-RateLimit-Reset: 1705312800| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests per minute |
X-RateLimit-Remaining | Remaining requests in current window |
X-RateLimit-Reset | Unix timestamp when the limit resets |
Rate Limit Exceeded
Section titled “Rate Limit Exceeded”When you exceed the limit, you’ll receive a 429 response:
{ "error": { "code": "rate_limit", "message": "Rate limit exceeded", "retry_after": 45 }}The Retry-After header indicates seconds to wait:
HTTP/1.1 429 Too Many RequestsRetry-After: 45Best Practices
Section titled “Best Practices”- Monitor rate limit headers to track remaining requests proactively.
- Implement exponential backoff for retries.
- Queue requests to spread them over time.
- Cache responses to reduce unnecessary API calls.
- Use webhooks to subscribe to events instead of polling.
Handling Rate Limits
Section titled “Handling Rate Limits”async function fetchWithRetry(url, options, maxRetries = 3) { for (let i = 0; i < maxRetries; i++) { const response = await fetch(url, options);
if (response.status === 429) { const retryAfter = response.headers.get('Retry-After') || 60; await sleep(retryAfter * 1000); continue; }
return response; } throw new Error('Max retries exceeded');}