Overview
World Monitor implements IP-based rate limiting to ensure fair usage and protect against abuse. Rate limits are enforced using Upstash Redis with a sliding window algorithm.Rate Limit Details
Global Rate Limit
All API endpoints share a single global rate limit:Maximum requests per window
Sliding window duration (60 seconds)
Rate Limit Algorithm
Upstash Ratelimit uses a sliding window algorithm:- Smooth rate limiting (no burst at window boundaries)
- More accurate than fixed windows
- Prevents “thundering herd” at window reset
IP Address Detection
Rate limits are applied per client IP address. The API uses the following priority:x-real-ip- Vercel/Cloudflare TCP connection IP (cannot be spoofed)cf-connecting-ip- Cloudflare connecting IPx-forwarded-for- First IP in chain (less trusted)- Fallback:
0.0.0.0
Rate Limit Headers
All API responses include rate limit information in headers:Maximum requests allowed in the window (e.g., “300”)
Requests remaining in current window
Unix timestamp (milliseconds) when the window resets
Seconds to wait before retrying (only on 429 responses)
Example Response Headers
Rate Limit Exceeded
When the rate limit is exceeded, the API returns: Status Code:429 Too Many Requests
Response Body:
Handling 429 Responses
Upstash Integration
Rate limiting is powered by Upstash Redis, a serverless Redis service optimized for edge functions.Configuration
Rate limiting requires two environment variables:If Upstash credentials are not configured, rate limiting is disabled and all requests are allowed.
Implementation
Rate Limit Storage
Upstash stores rate limit counters with:- Key prefix:
rl(configurable) - Key format:
rl:{ip-address} - TTL: Automatically managed by sliding window
- Analytics: Disabled for performance
Best Practices
1. Implement Exponential Backoff
2. Monitor Rate Limit Headers
3. Batch Requests
Use batch endpoints when available:4. Use Edge Caching
Leverage built-in edge caching for cacheable endpoints:Rate Limit Exemptions
The following scenarios are exempt from rate limiting:- Failed authentication (401/403) - Returns before rate limit check
- OPTIONS preflight requests - CORS preflight doesn’t consume quota
- Upstash unavailable - Rate limiting is disabled if Redis is unreachable
Error Handling
If Upstash Redis is unavailable:Rate limiting gracefully degrades. If Upstash is unavailable, requests are allowed through to prevent service disruption.
Increasing Rate Limits
The default rate limit (300 req/min) is designed for typical usage. If you need higher limits:- Contact Support: Reach out to the World Monitor team
- Provide Justification: Explain your use case and expected load
- Custom Configuration: Receive dedicated rate limit tier
Monitoring and Analytics
Rate limit metrics are available:- Response Headers: Real-time limit/remaining/reset info
- 429 Responses: Track rate limit exceeded events
- Upstash Dashboard: View Redis usage and performance (if enabled)
Analytics are currently disabled (
analytics: false) for performance. This may be enabled in future versions.Next Steps
Authentication
Learn about API keys and CORS
API Reference
Explore available endpoints