API Rate Limiting: Algorithms, Headers & Best Practices
How to implement API rate limiting: token bucket, sliding window, leaky bucket algorithms. With headers and response codes.
Rate Limiting Algorithms
- Fixed window: Simple but allows bursts at window boundaries
- Sliding window: Smoother distribution, slightly more complex
- Token bucket: Allows bursts up to bucket size, then throttles. Most common.
- Leaky bucket: Processes at constant rate, queues excess requests
Response Headers
X-RateLimit-Limit: 100\nX-RateLimit-Remaining: 23\nX-RateLimit-Reset: 1711120060\nRetry-After: 30 // on 429 responses
Try It Free
Use our free online tool — 100% client-side, no data leaves your browser.
Open HTTP Status Codes