Skip to main content

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:
number
default:"300"
Maximum requests per window
string
default:"60 s"
Sliding window duration (60 seconds)
Default: 300 requests per 60 seconds (5 requests/second average)

Rate Limit Algorithm

Upstash Ratelimit uses a sliding window algorithm:
Sliding Window Benefits:
  • 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:
  1. x-real-ip - Vercel/Cloudflare TCP connection IP (cannot be spoofed)
  2. cf-connecting-ip - Cloudflare connecting IP
  3. x-forwarded-for - First IP in chain (less trusted)
  4. Fallback: 0.0.0.0
The x-forwarded-for header can be client-settable. The API prioritizes x-real-ip from trusted infrastructure to prevent spoofing.

Rate Limit Headers

All API responses include rate limit information in headers:
string
Maximum requests allowed in the window (e.g., “300”)
string
Requests remaining in current window
string
Unix timestamp (milliseconds) when the window resets
string
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:
Response Headers:

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:
Cached responses don’t count against your rate limit after the first request in the cache window.

Rate Limit Exemptions

The following scenarios are exempt from rate limiting:
  1. Failed authentication (401/403) - Returns before rate limit check
  2. OPTIONS preflight requests - CORS preflight doesn’t consume quota
  3. 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:
  1. Contact Support: Reach out to the World Monitor team
  2. Provide Justification: Explain your use case and expected load
  3. Custom Configuration: Receive dedicated rate limit tier
Enterprise users can receive custom rate limits configured per API key.

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