Skip to main content

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

Need higher limits? Enterprise customers can request custom rate limits. Contact [email protected] for details.

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 a 429 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

Combine multiple operations into single requests:
This reduces the number of API calls and helps stay within rate limits.
Cache API responses to reduce redundant requests:
Use webhooks instead of polling:
See Webhooks for setup instructions.
Queue requests to control rate:
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
Typical approval time: 2-3 business days

Troubleshooting

Solutions:
  1. Optimize your code - Reduce unnecessary requests
  2. Implement caching - Cache responses when possible
  3. Use webhooks - Replace polling with event-driven updates
  4. Batch operations - Combine multiple requests
  5. Upgrade your plan - Get higher rate limits
Possible reasons:
  • Using an old API version
  • Proxy stripping headers
  • Client library not exposing headers
Solution: Ensure you’re using the latest API version and check your HTTP client configuration.
Check for:
  • Multiple instances of your application running
  • Shared API keys across services
  • Automated scripts or cron jobs
  • Development/staging environments using production keys
Solution: Use separate API keys for each environment and service.

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
Important: Rate limits are per API key. Using the same key across multiple services will share the rate limit.