Rate Limits
SplitRoute API implements rate limiting to ensure fair usage and system stability. This document explains the rate limits for different API key tiers and how to handle rate limit errors.
Rate Limit by Tier
Rate limits vary based on your API key tier:
Tier | Rate Limit |
---|---|
No AUTH | 1000 requests/hour shared |
FREE | 1000 requests/hour |
BASIC | 2000 requests/hour individual |
PRO | 5000 requests/hour individual |
ENTERPRISE | 20000 |
Rate Limit Headers
When you make a request to the SplitRoute API, the response includes headers that provide information about your current rate limit status:
HTTP
1 X-RateLimit-Limit: 60 2 X-RateLimit-Remaining: 58 3 X-RateLimit-Reset: 1609459200
X-RateLimit-Limit
: The maximum number of requests you can make per hourX-RateLimit-Remaining
: The number of requests remaining in the current rate limit windowX-RateLimit-Reset
: The time at which the current rate limit window resets (Unix timestamp)
Rate Limit Errors
If you exceed your rate limit, the API will return a 429 Too Many Requests
response with the following body:
JSON
1 { 2 "error": "rate_limit_exceeded", 3 "message": "Rate limit exceeded. Please try again later.", 4 "retry_after": 120 5 }
The retry_after
field indicates the number of seconds you should wait before making another request.
Best Practices
To avoid hitting rate limits, follow these best practices:
-
Implement exponential backoff: When you receive a rate limit error, wait for the specified
retry_after
period before retrying, and increase the wait time exponentially for consecutive failures. -
Cache responses: Cache responses that don't change frequently to reduce the number of API calls.
-
Use webhooks: Instead of polling for invoice status changes, use webhooks to receive notifications when events occur.
-
Monitor your usage: Keep track of your API usage and adjust your implementation if you're approaching your limits.
-
Upgrade your tier: If you consistently hit rate limits, consider upgrading to a higher API key tier.
Example: Handling Rate Limits
Here's an example of how to handle rate limits in your code:
JAVASCRIPT
1 async function makeApiRequest(url, options) { 2 let retries = 0; 3 const maxRetries = 5; 4 let retryAfter = 1; 5 6 while (retries < maxRetries) { 7 try { 8 const response = await fetch(url, options); 9 10 if (response.status === 429) { 11 const data = await response.json(); 12 retryAfter = data.retry_after || Math.pow(2, retries); 13 console.log(`Rate limit exceeded. Retrying in ${retryAfter} seconds.`); 14 await new Promise(resolve => setTimeout(resolve, retryAfter * 1000)); 15 retries++; 16 } else { 17 return response; 18 } 19 } catch (error) { 20 console.error('API request failed:', error); 21 throw error; 22 } 23 } 24 25 throw new Error('Maximum retries exceeded'); 26 }
Free Tier Limitations
The free tier has additional limitations:
- Limited to 1000 requests per hour for all users without an API Key
- No Limit for invoices
- Highest fees at 0.5% (still 5x cheaper than the competition)
- No Dashboard
Register to get an API KEY to remove these limitations. Or move to a paid tier to reduce the costs per transaction.