Skip to content

rate limit

A rate limit is a cap on how many requests a client can send to a service within a fixed window of time, such as one hundred requests per minute. Requests beyond the cap are rejected or delayed until the window resets.

Services impose rate limits to share capacity fairly among clients, to keep one runaway script from degrading the service for everyone, and to blunt abuse such as credential stuffing or scraping. Each client is usually identified by its API key, account, or IP address, and the service keeps a counter for that identity.

A few algorithms are common for deciding whether the next request fits under the limit:

  • Fixed window: Counts requests in consecutive intervals and resets the counter at each boundary, which allows short bursts right at the edge.
  • Sliding window: Counts requests over the trailing interval, which smooths out those edge bursts.
  • Token bucket: Adds tokens at a steady rate up to a maximum capacity and spends one per request, so the capacity sets the largest allowed burst.
  • Leaky bucket: Queues incoming requests and releases them at a constant rate.

The timeline below runs one stream of requests through all four algorithms under a limit of four requests per five seconds. Adding or removing requests shows which ones each limiter accepts, rejects, or delays:

Interactive diagram — enable JavaScript to view.

Over HTTP, a server signals an exceeded limit with status code 429 Too Many Requests, defined in RFC 6585. The response may carry a Retry-After header that gives the number of seconds to wait or a date to retry after. Clients typically respond by retrying with exponential backoff, which doubles the wait after each failed attempt. Adding a small random delay to each wait keeps a crowd of clients from retrying at the same moment.

Limits don’t always count requests. Large language model APIs also meter tokens per minute and per day, and many providers group accounts into usage tiers whose limits rise with spending or account history.

Python API Integration

Tutorial

Python and REST APIs: Interacting With Web Services

Learn to consume web services with the requests library, then explore the tools for building a Python REST API of your own.

intermediate api web-dev

For additional information on related topics, take a look at the following resources:

Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.


By Martin Breuss • Updated Nov. 22, 2026