# API Rate Limit (status code 429)

Rate limiting protects our systems from sudden bursts in traffic. When a request is rate limited, the API returns a 429 error code.

The current rate limit is 30 requests per second on all usage plans. Even if you send requests below the rate limit, you might still encounter 429 errors sometimes. There are a couple of reasons for this:

  • If our system receives a large increase in traffic, it will take some time to scale up, usually in the order of minutes. While this is happening, some requests might be knocked back with 429s.

  • If requests are sent at a rate close to the limit, some requests can still trigger rate limiting since our servers can receive requests at a different rate to which they are sent. For example, if you send 30 requests per second for 2 seconds, our servers might receive 25 requests in the first second, 33 in the next second (3 of which will be limited), and the remaining 2 requests after that. The rate at which our systems receive the requests will depend on network conditions, which are influenced by many factors outside of our control.

Both of these scenarios mean that 429s can occur sometimes, and they are more likely if requests are being sent close to the limit.

To handle a request that has been rate limited, consider retrying the request after a couple of seconds. Also avoid unnecessary API calls. For example, API calls to the sports or events endpoints can be made infrequently, since the responses don't change often.

# Reduce the likelihood of 429s

  1. It is highly recommended to combine multiple markets in the same request if you are not already doing so. Markets can be combined with a comma separator.
❌ If you need multiple markets, don't send one request per market

https://api.the-odds-api.com/v4/sports/americanfootball_nfl/odds?markets=h2h

https://api.the-odds-api.com/v4/sports/americanfootball_nfl/odds?markets=spreads

✅ Instead, combine markets into a single request using comma separators in the markets parameter

https://api.the-odds-api.com/v4/sports/americanfootball_nfl/odds?markets=h2h,spreads

The same applies if you are querying multiple regions.

  1. Reduce calls to endpoints that don't update frequently, such as /sports or /events endpoints. This can be done by caching the responses. The cache duration will depend on the needs of your application. For example, you might cache the /sports response for an hour, and the /events endpoint for 10 minutes.

  2. If an endpoint returns empty results (for example, immediately after a round of games, or if the sport is out of season), send requests less frequently until games become available again.

# Summary

  • Send requests below the rate limit
  • Expect 429s sometimes, especially if sending requests close to the rate limit. When a 429 is encountered, retry the request after a couple of seconds. If possible, space requests out over a longer time period rather than sending many requests in short bursts.
  • If you are querying multiple markets, ensure markets are combined into a single request rather than sending one request per market. The same applies to regions.
  • Send less frequent requests to endpoints that don't update frequently, such as the /sports and /events endpoints. Save or cache the response for use in between requests.
  • Send less frequent requests to endpoints that aren't returning any data