Skip to main content

Understanding Rate Limits

Why Rate Limits?

Rate limits are implemented to ensure the fair use and availability of our services to all users. By restricting the number of requests a user can make in a given time period, we can:

  • Protect the API from abuse or excessive use.
  • Ensure optimal performance and reliability for all users.
  • Manage and allocate server resources efficiently.

Monitoring Rate Limits

Each API response includes several headers that help you track your current rate limit status:

  • x-ratelimit-remaining: The number of requests left for the time window.
  • x-ratelimit-reset: The number of seconds until the rate limit is reset.
  • x-ratelimit-limit: The total number of requests permitted within the time window (default time window is 10 minutes).

Exemple headers:

x-ratelimit-remaining: 8
x-ratelimit-reset: 120
x-ratelimit-limit: 10

In this example, you can make 8 more requests in the next 120 seconds before hitting the rate limit.

What to Do When You Hit the Rate Limit

If you exceed the rate limit, your requests will be throttled and you will receive a 429 Too Many Requests HTTP status code. Here are steps to handle this situation:

  1. Pause Request Submissions: Stop sending requests until the rate limit period has been reset.
  2. Check the x-ratelimit-reset Header: This header tells you how long to wait before making another request.
  3. Implement Exponential Backoff: In your code, implement an exponential backoff strategy to progressively delay requests, ensuring compliance with the rate limit.
  4. Review Your Usage: Consider optimizing your API usage by caching responses or consolidating requests where possible.
  5. Request a higher limit Contact Askås and explain your need for a higher limit.