Tracking Your API Usage to Avoid Exceeding Rate Limits

Use this procedure to track your API usage. Your API usage is listed in the output headers.

You can track your current API usage by looking at the following headers in the JSON response to your API queries:

X-RateLimit-Limit-day
Indicates how many queries are permitted per day
X-RateLimit-Remaining-day
Indicates how many queries you have left in the current day
X-RateLimit-Limit-hour
Indicates how many queries are permitted per hour
X-RateLimit-Remaining-hour
Indicates how many queries you have left in the current hour
X-RateLimit-Limit-minute
Indicates how many queries are permitted per minute
X-RateLimit-Remaining-minute
Indicates how many queries you have left in the current minute
X-RateLimit-Limit-second
Indicates how many queries are permitted per second
X-RateLimit-Remaining-second
Indicates how many queries you have left in the current second

Best Practice for Tracking API Usage

You can use the rate limit headers to track your API rate limit usage by storing the current rate limit values after every API call. You compare the rate limit values in related headers to see the usage as shown in the following example:

  • X-RateLimit-Limit-minute: 3 and X-RateLimit-Remaining-minute: 2

  • X-RateLimit-Limit-hour: 50 and X-RateLimit-Remaining-hour: 48

  • X-RateLimit-Limit-day: 300 and X-RateLimit-Remaining-day: 290

  • LastCallMade: July 10, 2024 23:00:01Z

You can use the values in these seven headers, along with the current time before making the API call, to determine whether the call will exceed the rate limit allowance and return a 429 error or stay within the allowance.