Handling API Rate Limit Warnings


#1

Something API users may not be aware of, is that the Solcast API has (at the time of writing) a default rate limit of 120 requests per minute per user.

If you’re using one of our client libraries like solcast-py for Python, you won’t need to worry about this as it already handles batching requests to fall within the rate limit.

If you’re just using a plain HTTP client to make requests to the Solcast API, there are response headers that you can read to make you client handle being rate limited easier.

  1. x-rate-limit specifies what the rate limit is per minute.
  2. x-rate-limit-remaining specifies how many additional requests you can make until the rate limit is exceeded.
  3. x-rate-limit-reset specifies when (UTC in Unix Time format) the limit will reset

If you do happen to exceed you rate limit, you will receive a 429 status code in return, indicating you have exceeded your limit.

The simplest way to handle this in a client is to:

  1. Handle error responses
  2. Check if it is a 429 status code,
  3. Deduct the now in UTC in Unix standard from x-rate-limit-reset and;
  4. Wait the number of seconds that results from step 3 and continue from the last request made.

This will ensure you can get the most out of the Solcast API!

Hopefully the above will makes things easier for users hitting the rate limit. What kind of tools/programming languages/etc are others using to access the API?