HTTP 429 Too Many Requests
HTTP 429 Too Many Requests is the status code a server returns when a client has sent too many requests in a given amount of time and hit the rate limit. The code was introduced in RFC 6585 in 2012. The standard does not say how requests are counted — per key, IP address or resource, per second or per hour — so every service sets its own rules.
How to handle a 429
This function requests the funding spread and retries after 429 and 503 responses:
import os
import time
import requests
URL = "https://api.genesisarbitrage.com/v1/funding/spread"
HEADERS = {"X-API-Key": os.environ["GENESIS_API_KEY"]}
def get_with_retry(params, attempts=5):
delay = 1
for _ in range(attempts):
r = requests.get(URL, headers=HEADERS,
params=params, timeout=10)
if r.status_code not in (429, 503):
r.raise_for_status()
return r.json()["data"]
wait = r.headers.get("Retry-After", "")
# the server's pause if given, else 1, 2, 4… seconds
time.sleep(int(wait) if wait.isdigit() else delay)
delay = min(delay * 2, 60)
raise RuntimeError("still rate limited: poll less often")
rows = get_with_retry({"min_spread": 0.05})
print("coins with a funding spread of 0.05% or more:", len(rows))
Doubling the pause is called exponential backoff. A retry with no pause will most likely get another 429. If several copies of a bot send requests, add a random fraction of a second to each pause so their retries do not arrive at the same moment.
429 in Genesis API
Genesis API returns 429 with one of two codes in the response body, plus a Retry-After header:
| Code | When | What to do |
|---|---|---|
rate_limited | Requests-per-second limit exceeded: from 1 on Trial to 15 on Max | Wait for Retry-After, spread requests over time |
download_limited | Over 60 MB of compressed data per 10 seconds per key | Wait for the window to end, narrow the query with filters and coin |
{
"success": false,
"error": {
"code": "rate_limited",
"message": "Requests per second limit exceeded."
}
}
Requests over the limits are never billed: only a 200 response counts as a call, and a 429, like any other error, does not use your quota. Errors still count toward the requests-per-second limit, though, so rapid retries trigger new 429s. The X-RateLimit-Remaining header shows what is left in the current window, and X-Quota-Remaining shows the remaining quota.
See also: API polling, ETag and If-None-Match, errors in the Genesis API docs, Genesis API limits.
Questions and answers
How is 429 different from 503?
429 means you are asking too often. In Genesis API, 503 with the snapshot_not_ready code means the data is being rebuilt or its source is restarting: retry after Retry-After seconds.
Why do I get 429 when my bot sends few requests?
The limit is per key, so two scripts sharing one key share the limit. Another cause is frequent full downloads without filters that run into the download_limited volume cap.