Rate Limits
NabooPay uses rate limiting to ensure API stability for all users.
Limits
100 requests per 60 seconds
Rate limits use a sliding window algorithm - your request count is tracked over the last 60 seconds.
Rate Limit Response
When you exceed the limit, you'll receive:
HTTP/1.1 429 Too Many Requests
{
"error": "Rate limit exceeded. Try again later."
}
Handling Rate Limits
Implement Backoff
async function fetchWithBackoff(url, options, maxRetries = 3) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
const response = await fetch(url, options);
if (response.status === 429) {
// Wait with exponential backoff: 1s, 2s, 4s
const delay = Math.pow(2, attempt) * 1000;
await new Promise(resolve => setTimeout(resolve, delay));
continue;
}
return response;
}
throw new Error('Rate limit: max retries exceeded');
}
Batch Operations
Instead of many small requests, batch when possible:
// Instead of checking multiple transactions individually
for (const id of orderIds) {
await fetch(`/transactions/${id}`); // Many requests
}
// Fetch all at once with filters
await fetch('/transactions?status=pending&limit=100'); // One request
Cache Responses
Cache data that doesn't change frequently:
let cachedAccounts = null;
let cacheTime = 0;
async function getAccounts() {
// Cache for 5 minutes
if (cachedAccounts && Date.now() - cacheTime < 300000) {
return cachedAccounts;
}
const response = await fetch('/api/v2/accounts', {
headers: { 'Authorization': `Bearer ${API_KEY}` }
});
cachedAccounts = await response.json();
cacheTime = Date.now();
return cachedAccounts;
}
Best Practices
- Don't poll aggressively - Use webhooks instead of polling for status changes
- Batch list operations - Use pagination and filters instead of individual fetches
- Cache account data - Balance checks don't need to be real-time
- Queue requests - Spread requests over time instead of bursting