API Directory โ€บ Guides โ€บ API Rate Limiting Explained (and How to Handle It)

API Rate Limiting Explained (and How to Handle It)

APIs limit how often you can call them. Here's why, how to spot when you've hit a limit, and how to stay under it.

Rate limiting is how an API caps how many requests you may send in a given window — per second, per minute, per day, or per month. It protects the service from overload and abuse, and on paid APIs it’s also how tiers are enforced. Hit the limit and you get HTTP 429.

How limits are expressed

Read the headers

Most APIs tell you where you stand on every response. Names vary, but the pattern is:

X-RateLimit-LimitYour ceiling for the current window
X-RateLimit-RemainingHow many requests you have left
X-RateLimit-ResetWhen the window resets — Unix seconds, or seconds-from-now
Retry-AfterOn a 429/503: how many seconds to wait before trying again

Handle 429 properly: exponential backoff with jitter

import time, random, requests

def get(url, **kw):
    for attempt in range(5):
        r = requests.get(url, timeout=10, **kw)
        if r.status_code != 429:
            r.raise_for_status()
            return r
        # prefer the server's hint, else back off exponentially
        wait = float(r.headers.get('Retry-After', 2 ** attempt))
        wait += random.uniform(0, 0.5)      # jitter avoids thundering herd
        time.sleep(wait)
    raise RuntimeError('rate limit: gave up after 5 attempts')

The jitter matters: if every client retries after exactly 2 seconds, they all hammer the API again at the same instant. A small random offset spreads them out.

Better: don’t hit the limit in the first place

Per-key, per-IP, or per-user?

Know which one applies. If the limit is per API key and you call a third-party API directly from every user’s browser with the same key, one busy user can exhaust the quota for everyone — proxy through your backend and apply your own fair-use limits. If it’s per IP, serverless functions sharing an egress IP can collide. Design for the dimension the API actually meters.

FAQ

What does HTTP 429 mean?

429 Too Many Requests means you’ve exceeded the API’s rate limit. Check the Retry-After header for how long to wait, then retry with backoff.

What is exponential backoff?

A retry strategy where the wait between attempts roughly doubles each time (1s, 2s, 4s, 8s…), usually with a little random jitter added and a cap on the number of attempts. It relieves a struggling API instead of hammering it.

How can I avoid rate limits entirely?

Cache responses, batch multiple items into one request, throttle your client so it never exceeds the documented rate, stagger background jobs, and use webhooks instead of polling where the API supports them.

Is the rate limit per API key or per IP address?

It depends on the API — check the docs. Per-key limits mean all traffic using that key shares the quota; per-IP limits can catch out serverless functions that share an egress IP.

Keep going

Try it on a real API

Browse all 196 free APIs โ†’

๐Ÿ”Œ Explore free public APIs

Hundreds of free APIs, searchable by category, with auth & CORS at a glance.

Browse the directory โ†’