Rate Limiting
The Tewdy API uses rate limiting to ensure fair usage and protect the platform from abuse. Rate limits are applied per user (authenticated) or per IP (unauthenticated).
Rate Limit Headers
Every API response includes headers indicating your current rate limit status:
| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests allowed in the current window |
X-RateLimit-Remaining | Requests remaining in the current window |
X-RateLimit-Reset | ISO 8601 timestamp when the window resets |
Retry-After | Seconds until the next request is allowed (on 429) |
Default Limits
| Endpoint Type | Limit | Window |
|---|---|---|
| General API | 100 requests | 1 minute |
| API key creation | 20 requests | 1 minute |
| Task creation | 1 task/day (free) | 24 hours |
| Task creation (premium) | 5 tasks/day | 24 hours |
Handling 429 Errors
When you exceed a rate limit, the API returns a 429 Too Many Requests response:
{
"message": "Too many requests, please try again later.",
"status": 429
}Best Practices
-
Check the headers. Before retrying, read
X-RateLimit-Remainingto know if you’re close to the limit. -
Use the
Retry-Afterheader. When you receive a 429, wait the number of seconds indicated before retrying. -
Implement exponential backoff. For automated systems, use exponential backoff with jitter:
async function fetchWithRetry(url, options, maxRetries = 3) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
const response = await fetch(url, options);
if (response.status === 429) {
const retryAfter = parseInt(response.headers.get('Retry-After') || '5', 10);
const delay = retryAfter * 1000 * Math.pow(2, attempt) + Math.random() * 1000;
await new Promise(resolve => setTimeout(resolve, delay));
continue;
}
return response;
}
throw new Error('Max retries exceeded');
}-
Cache responses. For read-heavy workloads, cache task data locally to reduce API calls.
-
Batch operations. Where possible, fetch multiple resources in a single request using query parameters rather than making individual requests.
Rate Limits for API Keys
API key requests count against the authenticated user’s rate limit, not a separate API key limit. This means requests made via JWT and API key share the same quota.