Rate Limits and API Authentication
API Key Authentication (Optional)
For production use, you may need an API key for rate limiting and tracking purposes. Include your API key in the request header:
X-API-Key: your-api-key-here
note
During development and testing, the API key is optional. For production deployments, contact the Xplore team to obtain an API key.
Example Request with Authentication
curl -X GET "https://xplore.api.v2.routerprotocol.com/v1/quote?fromChain=1&..." \
-H "X-API-Key: your-api-key-here" \
-H "Content-Type: application/json"
Rate Limiting
Default Limits
| Tier | Requests per Minute | Requests per Hour |
|---|---|---|
| Free | 60 | 1,000 |
| Standard | 300 | 10,000 |
| Enterprise | Custom | Custom |
Rate Limit Headers
Response headers indicate your current rate limit status:
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1640000000
Handling Rate Limits
When you exceed your rate limit, you'll receive a 429 Too Many Requests response. Implement exponential backoff for retries:
async function fetchWithRetry(url, options, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
const response = await fetch(url, options);
if (response.ok) return response;
if (response.status === 429) {
// Rate limited - wait before retry
const retryAfter = response.headers.get('Retry-After') || Math.pow(2, i);
await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
continue;
}
if (response.status >= 500) {
// Server error - retry with backoff
await new Promise(resolve => setTimeout(resolve, Math.pow(2, i) * 1000));
continue;
}
// Client error - don't retry
throw new Error(`HTTP ${response.status}`);
} catch (error) {
if (i === maxRetries - 1) throw error;
}
}
}