Overview
To ensure fair usage and maintain optimal performance, the Smartbills API implements rate limiting using the Leaky Bucket algorithm. This helps control incoming request traffic and provides a smooth, predictable API experience for all users.Fair usage: Rate limits ensure that no single user can monopolize API resources, maintaining quality service for everyone.
Rate Limiting Policy
Current Limits
Rate Limit Headers
Every API response includes rate limit information in the headers:integer
Maximum number of requests allowed per minute
integer
Number of requests remaining in the current window
integer
Unix timestamp when the rate limit resets
How the Leaky Bucket Works
The Leaky Bucket algorithm provides smooth traffic shaping:1
Bucket Capacity
The bucket has a fixed capacity representing the maximum number of requests that can be stored temporarily.
2
Leak Rate
The bucket leaks at a constant rate, allowing a specific number of requests to be processed per second.
3
Request Handling
- When a request arrives, it’s added to the bucket if space is available
- If the bucket is full, the request is rejected with a 429 error
- Requests are processed at the leak rate, ensuring steady flow
Why Leaky Bucket?
Advantages:- ✅ Prevents traffic bursts from overwhelming the system
- ✅ Provides predictable request processing
- ✅ Allows short bursts up to bucket capacity
- ✅ Smooths out traffic spikes automatically
Rate Limit Exceeded Response
When you exceed the rate limit, you’ll receive a429 Too Many Requests response:
Response Headers
integer
Number of seconds to wait before retrying
Handling Rate Limits
Check Rate Limit Headers
Always monitor rate limit headers in your application:Implement Exponential Backoff
When you receive a 429 error, implement exponential backoff:Rate Limit Aware Client
Create a client that automatically handles rate limiting:Best Practices
Batch Requests
Batch Requests
Combine multiple operations into single requests:This reduces the number of API calls and helps stay within rate limits.
Cache Responses
Cache Responses
Cache API responses to reduce redundant requests:
Use Webhooks
Use Webhooks
Implement Request Queuing
Implement Request Queuing
Queue requests to control rate:
Monitor Usage
Monitor Usage
Track your API usage:
Rate Limit Strategies
Strategy 1: Proactive Throttling
Slow down before hitting the limit:Strategy 2: Token Bucket
Implement your own token bucket:Quota Extensions
Request Higher Limits
Enterprise customers can request custom rate limits: Contact information:- Email: [email protected]
- Include:
- Your use case
- Expected request volume
- Business justification
- Current plan details
Troubleshooting
Consistently hitting rate limits
Consistently hitting rate limits
Solutions:
- Optimize your code - Reduce unnecessary requests
- Implement caching - Cache responses when possible
- Use webhooks - Replace polling with event-driven updates
- Batch operations - Combine multiple requests
- Upgrade your plan - Get higher rate limits
Rate limit headers missing
Rate limit headers missing
Possible reasons:
- Using an old API version
- Proxy stripping headers
- Client library not exposing headers
Unexpected 429 errors
Unexpected 429 errors
Check for:
- Multiple instances of your application running
- Shared API keys across services
- Automated scripts or cron jobs
- Development/staging environments using production keys
Related Resources
Webhooks
Use webhooks instead of polling
Error Handling
Handle rate limit errors
Pagination
Efficiently paginate results
API Keys
Manage your API keys
Summary
- ✅ Monitor rate limit headers in every response
- ✅ Implement exponential backoff for 429 errors
- ✅ Use caching to reduce redundant requests
- ✅ Batch operations when possible
- ✅ Consider webhooks instead of polling
- ✅ Track your usage patterns
- ✅ Upgrade plan if consistently hitting limits