To ensure fair usage and service stability, the API implements rate limiting.
| Limit | Value |
|---|---|
| Max quotes per request | 10 |
| Max requests per minute | 10 |
| Max quotes per hour | 200 |
Every response includes rate limit information in the headers:
X-RateLimit-Limit-Requests: 10
X-RateLimit-Limit-Quotes: 200
X-RateLimit-Remaining: 150
X-RateLimit-Reset: 2024-01-15T11:00:00Z
| Header | Description |
|---|---|
X-RateLimit-Limit-Requests | Max requests per minute |
X-RateLimit-Limit-Quotes | Max quotes per hour |
X-RateLimit-Remaining | Remaining quota |
X-RateLimit-Reset | When the limit resets (ISO 8601) |
When you exceed the rate limit, you'll receive a 429 Too Many Requests response:
{
"statusCode": 429,
"statusMessage": "Too Many Requests",
"message": "Rate limit exceeded. You have 0 quotes remaining. Limit resets at 2024-01-15T11:00:00Z (in 45 seconds). Limits: 10 requests/min, 200 quotes/hour."
}
Store API responses locally to reduce repeated requests:
const CACHE_DURATION = 5 * 60 * 1000; // 5 minutes
let cache = { data: null, timestamp: 0 };
async function getQuotes() {
const now = Date.now();
if (cache.data && now - cache.timestamp < CACHE_DURATION) {
return cache.data;
}
const response = await fetch('https://quotegallery.nl/api/quotes?limit=10');
cache.data = await response.json();
cache.timestamp = now;
return cache.data;
}
Request multiple quotes at once instead of making individual requests:
# Good: One request for 10 quotes
curl "https://quotegallery.nl/api/quotes?limit=10"
# Bad: 10 separate requests
# curl "https://quotegallery.nl/api/quotes?limit=1" (x10)
For "load more" functionality, use exclude_ids to avoid fetching duplicates:
let seenIds = [];
async function loadMore() {
const params = new URLSearchParams({
limit: '10',
exclude_ids: seenIds.join(',')
});
const response = await fetch(`https://quotegallery.nl/api/v1/quotes?${params}`);
const { data } = await response.json();
seenIds.push(...data.map(q => q.id));
return data;
}
async function fetchWithRetry(url, retries = 3) {
const response = await fetch(url);
if (response.status === 429 && retries > 0) {
const resetTime = response.headers.get('X-RateLimit-Reset');
const waitTime = new Date(resetTime) - Date.now();
await new Promise(resolve => setTimeout(resolve, Math.max(waitTime, 1000)));
return fetchWithRetry(url, retries - 1);
}
return response;
}
Contact us if you need higher rate limits for your application.