View on GitHub

Rate limiting with a token bucket

Backend planned

How an API tells you to slow down.

The idea

APIs protect themselves by limiting how many requests each client can make. The token bucket is the classic algorithm: tokens drip into a bucket at a steady rate, each request spends one, and an empty bucket means wait.

It allows short bursts while enforcing an average rate, which is why so many APIs use it.

What the lesson will build

Key ideas

The video

When it’s published, the code will live in backend/ and this page will link to it.


All topics · Suggest a topic