Reference

Rate Limiting

Rate limiting for TMDB-backed requests and recommendation generation

TMDB-backed requests and recommendation generation are rate-limited using Upstash Ratelimit with Upstash Redis.

Limits

LimiterLimitWindowKey
tmdbLimiter40 requests1 secondGlobal key tmdb:global
recommendationLimiter10 requests1 dayAuthenticated user ID

The TMDB limiter uses a fixed window. The recommendation limiter uses a sliding window.

Response Headers

TMDB-backed responses include:

HeaderDescription
X-RateLimit-LimitTotal requests allowed in the window
X-RateLimit-RemainingRequests remaining in the current window
X-RateLimit-ResetTimestamp (ms) when the window resets

The TMDB helper also emits:

  • X-TMDB-RateLimit-Limit
  • X-TMDB-RateLimit-Remaining
  • X-TMDB-RateLimit-Reset

Recommendation generation responses include the standard X-RateLimit-* headers with the per-user daily quota values.

Rate Limit Exceeded

When the TMDB limit is exceeded the server responds with 429 Too Many Requests:

{
  "statusCode": 429,
  "message": "Rate limit exceeded for TMDB API. Please try again later."
}

When the recommendation limit is exceeded the server responds with 429 and a daily quota message.

Implementation

The limiters are defined in their owning utility domains and applied in:

  • server/utils/tmdb/rate-limit.ts before outbound TMDB requests (tmdbLimiter)
  • server/utils/recommendations/rate-limit.ts for authenticated recommendation generation (recommendationLimiter)

Environment Setup

Two Upstash Redis environment variables are required:

UPSTASH_REDIS_REST_URL=https://your-db.upstash.io
UPSTASH_REDIS_REST_TOKEN=your_token_here

Get these from Upstash console after creating a Redis database.

Copyright © 2026