# Rate limits for web scraping, read from the server's side

A rate limit is how many requests a server takes from one client in a time window. How servers count, the headers that state the limit, and one dated reading.

Canonical: https://spider.cloud/learn/rate-limits/

A rate limit is a cap a server sets on what one client may ask of it over time, such as requests per hour or requests open at once. A scraper over the cap is refused or slowed, and many servers report the quota, what is left and the reset in response headers.

The limit belongs to the server. You can guess at it from errors, but a server that reports its counters has already given you the answer, and reading them costs nothing.

## Why a server counts requests

A server has a fixed amount of work it can do, and every client shares it. The IETF draft on rate limit headers lists the reasons in its introduction: "Servers use quota mechanisms to avoid overload, to ensure an equitable distribution of computational resources, or to enforce other policies such as monetization." The same draft notes that the count can be kept on many keys: "Quotas may be enforced on different bases (e.g. per user, per IP, per geographic area) and at different levels."

The key decides whose requests share your count. GitHub's documentation describes its own key for visitors with no token: "Unauthenticated requests are associated with the originating IP address, not with the user or application that made the request." Everything that leaves from one address draws on one allowance. Send a token, and the count moves to your account.

So your count can include other people's requests. The operator sets the size of each share, and it need not track one machine's capacity. A limit can cover a whole fleet of servers, or exist to enforce a plan or a policy rather than to protect the hardware.

## What a limit is made of

Most limits come down to the same parts.

1. A quota, the number of units you may spend. Usually a unit is one request. The draft also defines units of bytes and of requests open at once.
2. A window, the stretch of time the quota covers. GitHub states its main one in plain numbers: "The primary rate limit for unauthenticated requests is 60 requests per hour."
3. A partition, the key the server counts by, as above.

A server can run several limits at the same time. GitHub keeps separate counts for search, for its GraphQL API and for ordinary REST calls, and it adds what it calls secondary limits on top of those.

This clip reads the three rate limit headers from one dated response, then shows two counts that reset at different times.

How to read rate limit headers. 1 min 2 s, no sound. The words are on screen, and the captions button shows them at your own text size.

Read the transcript

How to read rate limit headers. A quota, what is left of it, and when it resets.

Many servers report the quota, what is left and the reset in headers. The request reads: GET /rate_limit. The response reads: 200 OK. x-ratelimit-limit: 60. x-ratelimit-remaining: 60. x-ratelimit-reset: 1795228803. x-ratelimit-limit is read: the quota. x-ratelimit-remaining is read: what is left. x-ratelimit-reset is read: the reset, in epoch seconds. 60: requests in one window. 60: left in this window. 02:40:03: UTC, when the count resets.

One server can keep several counts. Each has its own quota and reset. The request was made at 01:40:02 UTC. core has 60 of 60 left. It resets at 02:40:03 UTC, 3601 s after this request. search has 10 of 10 left. It resets at 01:41:03 UTC, 61 s after this request. 2: counts, each with its own reset. 3601 s: until core resets. 61 s: until search resets.

Spend all 60 and core waits for its reset. Search keeps its own count. The request was made at 01:40:02 UTC. With every request spent, core has 0 of 60 left. It resets at 02:40:03 UTC, 3601 s after this request. search has 10 of 10 left. It resets at 01:41:03 UTC, 61 s after this request. 0: left of 60, once all are spent. 02:40:03: UTC, when core can ask again. 3601 s: to wait, from this request.

A refusal alone does not say which limit you hit. Read the headers first. When you are refused: 403 or 429. 0 left: Wait until the reset time. header: Wait what Retry-After says. neither: Wait at least one minute.

Read the full page. The page is at spider.cloud/learn/rate-limits.

## How a server states the limit

There are two common ways to put the counters in a response.

The older way is a family of headers with an `x-` prefix. GitHub sends five of them: `x-ratelimit-limit`, `x-ratelimit-remaining`, `x-ratelimit-used`, `x-ratelimit-reset` and `x-ratelimit-resource`. Its docs describe the reset header as "The time at which the current rate limit window resets, in UTC epoch seconds". Other APIs may name or count these differently, so read the docs of each one you call.

The newer way is the IETF draft, which defines two fields. One, RateLimit-Policy, states the policies. The other, RateLimit, gives, in the draft's words, "the quota currently available under specific policies at the time the response is generated". The draft's own examples look like this.

```text
RateLimit-Policy: burst;q=100;w=60,"daily";q=1000;w=86400
RateLimit: default;a=50;w=30
```

Read the first line as two policies: 100 requests per 60 seconds, and 1000 per day. In the second line, `a` is what is available now and `w` is the number of seconds that amount has to last. The window is a count of seconds, not a date, so your clock does not need to match the server's.

The draft is still a draft, and it expires in May 2027 unless a newer version replaces it. Expect the `x-` headers on most APIs for now.

## The counters on a dated run

The run asks GitHub's `/rate_limit` endpoint for its counters and keeps the five `x-ratelimit-` headers of the response. That one response carries the counters twice: once in the headers, for the resource the request itself counted against, and once in a JSON body with a set for each resource. GitHub's docs say which copy wins: "If the two disagree, rely on the response headers." Set `SPIDER_API_KEY` before you paste the request. `return_headers` asks the API to hand back the target's response headers with the page.

```bash
curl -s https://api.spider.cloud/scrape \
  -H "Authorization: Bearer $SPIDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://api.github.com/rate_limit", "request": "http", "return_format": "raw", "user_agent": "examplebot/1.0 (+https://example.com/bot; bot@example.com)", "return_headers": true}'
```

The run at 01:40:02 UTC on 2026-11-21 came back in one page. Below are the page's `url`, `status` and `error`, the five rate limit headers, and three pieces of the `content` field, copied as they arrived. The other headers and the other resources in the body are left out.

```text
url:     https://api.github.com/rate_limit
status:  200
error:   null

x-ratelimit-limit:     60
x-ratelimit-remaining: 60
x-ratelimit-used:      0
x-ratelimit-reset:     1795228803
x-ratelimit-resource:  core

content: "core":{"limit":60,"remaining":60,"reset":1795228803,"used":0}
content: "search":{"limit":10,"remaining":10,"reset":1795225263,"used":0}
content: "rate":{"limit":60,"remaining":60,"reset":1795228803,"used":0}
```

## What the numbers say

The headers name `core` as the resource and give the hourly limit from the docs: 60 requests, all 60 left and none used. The `core` line in the body says the same, so on this run the two copies agree. The call itself did not spend one. GitHub says of this endpoint: "Calling this endpoint does not count against your primary rate limit, but it can count against your secondary rate limit."

The reset of 1795228803 is 02:40:03 UTC on 2026-11-21, one hour and one second after the run started. With nothing used yet, this window had only just opened. On a busier address the reset would sit closer, and a client that had spent all 60 would wait only until that time, not a full hour from its last request.

The `search` line runs on a shorter clock. Its reset of 1795225263 is 01:41:03 UTC, 61 seconds after the run started, and its quota is 10. That is a separate count with a separate window, and spending it leaves `core` alone. The headers do not show it, because they describe only the resource this request counted against.

The `rate` line repeats `core`.

One warning comes from the same docs page. GitHub says these numbers can differ between responses, because requests are handled in more than one region, and it tells you to "avoid logic that depends on an exact remaining count". Use `remaining` to slow down early, and leave some of it unspent.

## When the count reaches zero

A refusal does not prove the quota is spent. GitHub answers with a 403 or a 429 for its primary limit and for its secondary limits alike, so the status code alone does not say which one you hit. When `x-ratelimit-remaining` is 0, the primary quota is gone, and the docs say "You should not retry your request until after the time specified by the" reset header. A secondary limit comes with an error message that names it and may carry a Retry-After header, which the [Retry-After page](/learn/retry-after/) explains. When no header gives a time, GitHub's advice is "Otherwise, wait for at least one minute before retrying."

The counters do not tell you everything. GitHub's secondary limits have no counter at all: "There is not a way to check the status of your secondary rate limit." The IETF draft gives the same warning in general terms: "Clients MUST NOT assume that a positive available quota is a guarantee that further requests will be served." A server may slow you down with quota still showing.

Going over again and again costs more than the wait. GitHub ends its section on going over with this: "Continuing to make requests while you are rate limited may result in the banning of your integration."

## Where a limit fits in a scrape

Most sites you scrape publish no counters at all. A refusal from one of them tells you that you were refused, not what the quota is or when it resets. So when you [scrape](/web-scraping/) a site like that, you set the limit yourself, with a slow [request rate](/learn/request-rate/) chosen before the first request. When a site does report its counters, the headers beat any guess.

## Do this, avoid this

### Do this

- Log the limit, remaining and reset headers on every response from an API that sends them.
- Convert a reset timestamp to UTC before you act on it, and check the docs in case the API sends seconds instead.
- Keep a separate count for each resource the server names, such as search and core.
- When remaining reaches 0, hold that resource until the reset time passes.
- Ask the operator for a token or a higher limit when the published quota is too small for the job.

### Avoid this

- Spending the whole quota in the first minute of the window.
- Retrying before the reset time after a response whose remaining header read 0.
- Assuming every 403 or 429 means the quota is spent; check the remaining header and the error message first.
- Counting on a positive remaining number to carry the next request.
- Running more clients from new addresses so each one gets a fresh quota.

Make the same call yourself, read `x-ratelimit-reset` from the headers, and turn it into a UTC time the way this page did. Your numbers will not match ours, but the sum works the same way, and its answer is how long a client that spent its last request would have to wait.

## Sources

1. [GitHub Docs, Rate limits for the REST API](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api) Read November 21, 2026
2. [IETF HTTPAPI working group, RateLimit header fields for HTTP, Internet-Draft, November 2026](https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-ratelimit-headers) Read November 21, 2026
