Rate limiting
How to protect your API and give tiered access to your API
Introduction
Rate limiting keys helps to prevent abuse to ensure fair usage and can be used to fix your customer’s usuage to their agreed access allowance.
Understanding Rate Limits
TheAuthAPI.com uses a standard rate limiting system. Each endpoint may have a different rate limit. The limits could be based on a time window, for example, a certain number of requests per minute.
Adding a limit
In this example, we’re creating a key that allows 10 requests per minute.
Checking Your Rate Limit Status When you make a request to TheAuthAPI.com, the response headers will include information about your current rate limit status:
Headers
ratelimit-limit
: The maximum number of requests you’re permitted to make per minute.ratelimit-remaining
: The number of requests remaining in the current rate limit window.ratelimit-reset
: The time at which the current rate limit window resets in UTC epoch seconds.ratelimit-consumed
: The number of requests consumed.
Good Result - 200
Rate limit hit - 429
Exceeding Rate Limits If you exceed the rate limit, TheAuthAPI.com will respond with a 429 Too Many Requests HTTP status code. You should handle this response in your application and implement a backoff and retry strategy.
Tips to Avoid Hitting Rate Limits Cache responses: To avoid unnecessary requests, cache responses whenever possible. Use exponential backoff: If you’re close to hitting your rate limit, or if you’ve exceeded it, use an exponential backoff strategy. This means gradually increasing the wait time between requests to reduce the load on the server. Use webhooks: If TheAuthAPI.com supports it, use webhooks to get updates instead of polling the API. Remember, rate limits are there to protect the service and ensure fair usage. Always respect the rate limits and use the API responsibly.