Rate Limiting
Rate Limiting
Section titled “Rate Limiting”TradeX APIs implement rate limiting to ensure fair usage and system stability.
Rate Limit Headers
Section titled “Rate Limit Headers”All API responses include rate limit information in headers:
X-RateLimit-Limit: 1000X-RateLimit-Remaining: 999X-RateLimit-Reset: 1640995200- X-RateLimit-Limit: Maximum number of requests allowed in the time window
- X-RateLimit-Remaining: Number of requests remaining in the current window
- X-RateLimit-Reset: Unix timestamp when the rate limit resets
Default Limits
Section titled “Default Limits”Rate limits vary by service and endpoint:
- Market Data API: 100 requests per second
- Order API: 10 requests per second
- Auth API: 5 requests per second
- User API: 20 requests per second
- Wallet API: 10 requests per second
Handling Rate Limits
Section titled “Handling Rate Limits”When you exceed the rate limit, you’ll receive a 429 Too Many Requests response:
{ "error": "Rate limit exceeded", "retry_after": 60}Best Practices
Section titled “Best Practices”- Implement exponential backoff: Wait progressively longer between retries
- Cache responses: Store frequently accessed data locally
- Batch requests: Combine multiple operations when possible
- Monitor headers: Track your rate limit usage
- Use WebSockets: For real-time data, use WebSocket connections instead of polling
WebSocket Rate Limits
Section titled “WebSocket Rate Limits”WebSocket connections have separate rate limits:
- Subscriptions: Limited by connection
- Messages: Throttled per channel type
- Reconnections: Limited to prevent abuse
See the WebSocket API documentation for details.