Why does Fleetio limit API request rates?
In order to maximize stability, the Fleetio API implements Rate Limiting to protect the platform against sudden spikes in traffic. API users who submit many requests in rapid succession may encounter this limit.
What are the limits?
The Fleetio API implements a simple throttle of 20 requests per minute.
Example
If 1 request is sent each second, starting at 12:00:18. Requests will begin to be rejected at 12:00:38. Subsequent requests will continue to be rejected until 12:01:00, at which point requests will be permitted until 12:01:20 if the current rate continues.
How will I know if the limit is exceeded?
Exceeding the limit will result in a response with a status code of HTTP 429 Too Many Requests
.
The body of the request will look like this:
Too many requests detected from your IP. Please try again later. If you believe this is an error, please contact Fleetio Support at [email protected]
The response will contain a header called Retry-After
, the value of this header will be the number of seconds until the rate limit will be lifted. At that point subsequent requests will succeed unless the rate limit is met again.
How can the limits be avoided?
The best way to avoid exceeding the limits is to design your system with the limits in mind. Here are some common strategies for avoiding the limits:
Sustained High Frequency Requests
One common use-cases where API users will encounter rate limiting is in submitting Location Entries or Meter Entries. Users often want to create these on a regular interval, once per minute, for example, or even more frequently. Creating Entries for multiple assets at high frequency can easily exceed the limit. If you anticipate sending more than 20 requests per minute, we recommend using the Bulk API to send a single requests to create more than one entry at a time.
A Sudden Burst of Requests
Another common use-case where users encounter the rate limit is if many requests are made for multiple resources in rapid succession. This sometimes happens when loading data for many related resources. Depending on your use-case, this can be improved with Filtering and Sorting. If you need help with this, feel free to reach out to Fleetio Support at [email protected] and we'll be happy to help you find a solution.
How should a 429 response be handled?
The best way to handle a 429 response, is to sleep for the number of seconds in the Retry-After
header, and then proceed.