Skip to main content

Rate limitation

The Rate Limitation page provides essential information about how the CodeNOW API handles rate limits to ensure fair usage and maintain optimal performance for all users. Understanding rate limitations is crucial for developers to design efficient and reliable applications that interact with the API.

What is Rate Limitation?

Rate limitation, also known as rate limiting, is a mechanism employed by the CodeNOW API to control the number of API requests a client can make within a specific time window. This measure prevents abuse, minimizes server load, and promotes fair usage among all users of the API.

Rate Limiting Policy

The CodeNOW API implements a rate limiting policy that allows a maximum of 100 requests per minute for each client. If a client exceeds this rate limit, the API will respond with an HTTP status code 429 Too Many Requests, indicating that the client's request cannot be processed at the moment due to the rate limitation. In such cases, the client should wait until the rate limit resets before making additional requests.

Rate Limit Headers

When making API requests, clients can check the response headers to determine their current rate limit status. The following headers are included in the API response:

  • x-ratelimit-limit: The maximum number of requests allowed for the specified time window. For the CodeNOW API, this value is set to 100.
  • x-ratelimit-remaining: The number of remaining requests that the client can make within the current time window. This value will decrease with each request and reset after the time window elapses.
  • x-ratelimit-reset: The time (in seconds) until the rate limit will reset, and the client's request allowance will be renewed.

Handling Rate Limit Exceeded

If a client exceeds the rate limit of 100 requests per minute, the API will respond with the status code 429 Too Many Requests. In such cases, the client should implement an exponential backoff strategy and retry the request after waiting for an appropriate amount of time. Exponential backoff involves progressively increasing the waiting time between retries, which helps prevent additional stress on the API servers.

Rate Limit Best Practices

To ensure smooth interactions with the CodeNOW API, developers are advised to follow these best practices:

  1. Implement Exponential Backoff: When rate limits are exceeded, employ an exponential backoff strategy to retry the request after progressively increasing waiting periods. This approach helps prevent additional stress on the API servers.
  2. Check Rate Limit Headers: Regularly inspect the rate limit headers in the API responses to monitor the remaining request allowance and time until reset. This allows your application to adapt its behavior dynamically based on the current rate limit status.
  3. Cache Responses: Whenever possible, cache API responses to reduce the number of redundant requests and minimize the risk of reaching rate limits.
  4. Stay Informed: Keep track of API announcements and updates to stay informed about any changes to the rate limitation policy. This enables you to adjust your application's behavior accordingly.

Conclusion

Understanding rate limitation is essential for building efficient, reliable, and compliant applications that interact with the CodeNOW API. By adhering to rate limits and following best practices, developers can ensure smooth interactions with the API while promoting fair usage and maintaining a high-quality experience for all users.