Rate Limiting
Understanding API rate limits and how to handle them.
Overview
Rate limiting protects the API from abuse and ensures fair usage across all users. When you exceed the rate limit, requests will return a 429 Too Many Requests response.
Current Limits
Booking Creation
10 requests/min
Per IP address
Per Schedule
30 requests/min
Prevents slot exhaustion
General API
100 requests/min
Per API key
Read Operations
300 requests/min
GET requests only
Response Headers
Rate limit information is included in response headers:
X-RateLimit-Remaining: 95
X-RateLimit-Limit: 100
X-RateLimit-Reset: 1704067260X-RateLimit-Remaining- Requests remaining in current windowX-RateLimit-Limit- Total requests allowed in windowX-RateLimit-Reset- Unix timestamp when window resets
Handling 429 Responses
When rate limited, you'll receive a 429 response with a Retry-After header:
{
"error": "Rate limit exceeded",
"code": "RATE_LIMITED",
"retry_after": 45
}The Retry-After header indicates seconds to wait before retrying.
Best Practices
1. Implement Exponential Backoff
When you receive a 429, wait and retry with increasing delays:
async function fetchWithRetry(url: string, options: RequestInit, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
const response = await fetch(url, options);
if (response.status === 429) {
const retryAfter = parseInt(response.headers.get('Retry-After') || '60');
const delay = retryAfter * 1000 * Math.pow(2, i); // Exponential backoff
await new Promise(resolve => setTimeout(resolve, delay));
continue;
}
return response;
}
throw new Error('Max retries exceeded');
}2. Cache Responses
Cache GET responses when possible to reduce API calls. Most list endpoints support pagination - fetch data once and cache it locally.
3. Use Webhooks
Instead of polling for updates, configure webhooks to receive real-time notifications when data changes.
4. Batch Requests
When fetching multiple resources, use filters and pagination to retrieve data in fewer requests rather than making individual calls.
Need Higher Limits?
If you require higher rate limits for your integration, contact us at api@webkasa.app with details about your use case.