Rate Limits
Rate limiting protects the QuizAPI infrastructure and ensures fair usage across all consumers. Limits are applied per IP address.
Current Limits
All API requests are rate limited to 60 requests per minute per IP address. When the limit is reached, subsequent requests will be rejected with a 429 status until the window resets.
| Scope | Limit | Window |
|---|---|---|
| Per IP address | 60 requests | 1 minute |
Response Headers
When rate limited, the API returns a Retry-After header indicating how many seconds to wait before retrying.
| Header | Present On | Description |
|---|---|---|
Retry-After | 429 responses | Number of seconds to wait before retrying (currently 60) |
Successful Response
HTTP/1.1 200 OK
Content-Type: application/json
Retry-After: 60
{
"success": true,
"data": [ ... ]
}When You Are Rate Limited
When your request rate exceeds the limit, the API returns a 429 Too Many Requests response with a Retry-After header indicating how many seconds to wait before retrying (60 seconds).
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Retry-After: 60
{
"success": false,
"error": "Rate limit exceeded. Please try again later."
}Best Practices
Cache responses client-side
Store API responses locally to avoid making redundant requests. Quiz data does not change frequently, so caching for a few minutes can dramatically reduce your request count.
Use exponential backoff
When you receive a 429 response, wait and retry with increasing delays. Add random jitter to prevent thundering herd problems when multiple clients retry simultaneously.
Monitor your usage via the dashboard
The Dashboard shows your real-time and historical API usage. Set up alerts to get notified before you approach your monthly limit.
Contact support for custom limits
If your application requires higher rate limits than what your current plan provides, reach out via email to discuss custom limits tailored to your needs.
Exponential Backoff Example
Here is a JavaScript utility function that automatically retries rate-limited requests with exponential backoff and jitter.
async function fetchWithBackoff(url, options, maxRetries = 3) {
for (let attempt = 0; attempt <= maxRetries; attempt++) {
const response = await fetch(url, options);
if (response.status !== 429) {
return response;
}
// Get the retry delay from the Retry-After header
const retryAfter = parseInt(
response.headers.get("Retry-After") || "1",
10
);
// Use exponential backoff with jitter
const delay = retryAfter * 1000 + Math.random() * 1000;
console.log(
`Rate limited. Retrying in ${Math.round(delay / 1000)}s ` +
`(attempt ${attempt + 1}/${maxRetries})`
);
await new Promise((resolve) => setTimeout(resolve, delay));
}
throw new Error("Max retries exceeded");
}Handling Rate Limits in Code
Check the response status code to detect rate limiting, and use the Retry-After header to determine when to retry.
// Check if you've been rate limited by inspecting the status code
const response = await fetch("https://quizapi.io/api/v1/quizzes", {
headers: { "Authorization": "Bearer YOUR_API_KEY" },
});
if (response.status === 429) {
const retryAfter = response.headers.get("Retry-After") || "60";
console.log(`Rate limited. Retry after ${retryAfter} seconds.`);
} else {
const data = await response.json();
console.log("Quizzes:", data.data);
}