Overview
The JOIP API implements rate limiting using a token bucket algorithm to protect against abuse and ensure fair resource allocation.Rate Limiting Algorithm
Token Bucket Implementation
The API uses an in-memory token bucket system:- Each user/IP starts with a full bucket of tokens
- Each request consumes one token
- Tokens refill gradually over time
- When tokens reach zero, requests are rejected with 429
Token Refill Logic
Rate Limit Policies
Public API Endpoints
Limit: 100 requests per 15 minutes per IP/api/sessions/*/api/media/*/api/community/*- Most authenticated endpoints
Reddit API Proxy
Limit: 30 requests per 5 minutes per IP/api/fetch-reddit- Reddit content fetching endpoints
Authentication Endpoints
Limit: 5 attempts per 15 minutes per IP/api/login- Authentication-related endpoints
Import Operations
Limit: 5 imports per 15 minutes per user/api/sessions/import-joip- Import-related endpoints
Payment Endpoints
Payment Callbacks
Limit: 60 requests per minute per IPPayment Creation
Limit: 10 requests per 15 minutes per userTelegram Webhooks
Limit: 100 requests per minute per IPRate Limit Headers
Every API response includes rate limit information:Example Response Headers
| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests allowed in window |
X-RateLimit-Remaining | Remaining requests in current window |
X-RateLimit-Reset | ISO timestamp when limit resets |
Rate Limit Exceeded Response
When rate limit is exceeded, you’ll receive: Status Code:429 Too Many Requests
Response Body:
| Field | Description |
|---|---|
error | Error type |
message | Human-readable error message |
retryAfter | Seconds until rate limit resets |
Example Response
Key Generation
Rate limits are applied per key. The key can be based on:IP Address (Default)
X-Forwarded-For header.
User ID (Authenticated Endpoints)
Special Behaviors
Skip Successful Requests
Some limiters don’t count successful requests:Skip Failed Requests
Some limiters don’t count failed requests:Token Refund Logic
Memory Management
Automatic Cleanup
Old buckets are cleaned up every minute:Best Practices
1. Monitor Rate Limit Headers
Always check response headers to track your usage:2. Implement Exponential Backoff
3. Batch Requests
Reduce API calls by batching when possible:4. Cache Responses
Cache API responses to reduce redundant requests:Rate Limit Summary Table
| Endpoint Type | Limit | Window | Key | Special Behavior |
|---|---|---|---|---|
| Public API | 100 requests | 15 minutes | IP | - |
| Reddit Proxy | 30 requests | 5 minutes | IP | Skip failed requests |
| Authentication | 5 attempts | 15 minutes | IP | Skip successful requests |
| Import | 5 imports | 15 minutes | User ID | - |
| Payment Callbacks | 60 requests | 1 minute | IP | - |
| Payment Creation | 10 requests | 15 minutes | User ID | - |
| Telegram Webhooks | 100 requests | 1 minute | IP | - |
Common Issues
Rate Limit Exceeded on Login
Problem: Can’t login after multiple failed attempts Solution: Wait 15 minutes or use different test accountRate Limit with VPN/Proxy
Problem: Shared IP hits rate limits quickly Solution:- Use authenticated endpoints (rate limited by user ID)
- Disable VPN for development
- Contact support for IP allowlist
Rate Limit in Development
Problem: Hitting limits during local testing Solution:- Use different test accounts to get separate limits
- Restart server to clear in-memory buckets
- Implement request caching
Next Steps
- Error Handling - Handle rate limit errors properly
- Authentication - User-based rate limiting
- API Introduction - Overview of all endpoints