What Are Rate Limits?
Rate limits are restrictions placed on the number of API requests a client can make within a specific time frame. These limits help ensure the stability and reliability of the service by controlling the load on the system and preventing misuse. They are essential for maintaining the performance and availability of the API for all users, ensuring that everyone has a fair opportunity to access and use the service.
Understanding and Working with Rate Limits
When using our API, it's important to be aware of the rate limits in place and plan your usage accordingly. Here’s how you can work within these limits:
Check Your Limits: each API endpoint may have its own specific rate limit. These limits are documented on the respective API endpoint pages in our developer portal. This ensures that the limits are appropriate for the specific operations being performed by that endpoint.
Rate Limit Headers:
When you make a request to our API, several headers are included in the response to help you understand your current rate limit status:
X-Rate-Limit-Limit
: This header specifies the maximum number of requests allowed within the current time window for the specific endpoint you are accessing. For example, if the limit for a specific endpoint is set to 1000 requests per minute, this header will return 1000.
X-Rate-Limit-Remaining
: This header indicates the number of requests remaining in the current time window before you reach the limit for that specific endpoint. Monitoring this value can help you avoid hitting the rate limit unexpectedly.
X-Rate-Limit-Reset
: This header provides the time (in Unix epoch format) when the rate limit window will reset, allowing you to make requests again. This helps in planning when to resume sending requests if you are close to or have already hit the limit.
Handle Rate Limit Responses: If you exceed your rate limit, the API will return a response with a status code of 429 Too Many Requests
. The response will include details such as the Retry-After
header, which specifies the number of seconds to wait before making a new request. Implement retry logic in your application to handle these situations gracefully.
Optimize API Usage
To avoid hitting rate limits, optimize your API usage by:
- Caching Responses: Store API responses locally (where appropriate) to minimize the need for repeated calls.
- Throttling Requests: Implement client-side throttling to spread out requests over time, reducing the likelihood of exceeding the limit.
- Monitor Usage: Regularly monitor your API usage to ensure you are staying within the limits. Most developer portals provide dashboards or tools to help track your consumption and identify any patterns that might lead to hitting limits.