API Rate Limits
The Forest Public API implements rate limiting to ensure service stability and fair usage across all customers. This guide explains rate limits, how to work with them, and best practices for building reliable integrations.Rate Limit Overview
Rate limits protect the API infrastructure by:- Preventing abuse - Limiting excessive or malicious requests
- Ensuring availability - Maintaining service for all users
- Encouraging efficiency - Promoting optimized API usage
- Fair resource allocation - Distributing capacity equitably
Current Rate Limits
Standard Limits
Enterprise Limits
Enterprise customers may have higher limits based on their plan. Contact your account manager for details.Rate limits are subject to change. Check the response headers for current limits.
Rate Limit Headers
Every API response includes headers with rate limit information:Header Definitions
X-RateLimit-Limit
- Maximum requests allowed in current time window
- Example:
60(60 requests per minute)
X-RateLimit-Remaining
- Requests remaining in current time window
- Example:
45(45 requests left)
X-RateLimit-Reset
- Unix timestamp when the rate limit resets
- Example:
1640995200(January 1, 2022, 00:00:00 UTC)
Reading Headers
JavaScript:429 Too Many Requests
Exceeding the rate limit causes the API to return a429 Too Many Requests error:
Response:
Retry-After Header
TheRetry-After header indicates how long to wait before retrying:
- Value in seconds until you can retry
- Always respect this value
- Do not retry before this time
Handling Rate Limits
Strategy 1: Check Headers Proactively
Monitor rate limit headers and slow down before hitting the limit:Strategy 2: Exponential Backoff
Implement exponential backoff for 429 errors:Strategy 3: Request Queue
Use a queue to control request rate:Strategy 4: Token Bucket
Implement a token bucket algorithm:Best Practices
1. Respect Rate Limits
Always check and respect rate limit headers:2. Implement Caching
Cache responses to reduce API calls:3. Batch Operations
Group related requests when possible:4. Use Pagination Efficiently
Request only the data you need:5. Monitor Usage
Track your API usage to identify optimization opportunities:6. Schedule Heavy Operations
Run intensive operations during off-peak hours:Increasing Rate Limits
Enterprise Plans
Enterprise customers can request higher rate limits:- Contact your account manager
- Describe your use case
- Provide expected request volume
- Discuss SLA requirements
Custom Limits
For specific high-volume use cases, custom limits may be available:- Bulk data exports
- Real-time integrations
- Data warehouse syncing
- Compliance reporting
Complete Example
Full implementation with rate limiting, retries, and monitoring:Next Steps
Authentication
Learn about API authentication
Activity Logs
Start using the Activity Logs API
API Introduction
Back to API overview
Best Practices
Review best practices