Rate limits
Limits
Section titled “Limits”| Limit | Set by | When exceeded |
|---|---|---|
| Requests per minute, per key | Your plan (a key can have a lower limit of its own) | 429 rate_limited |
| Requests per minute, per organization | Your plan | 429 rate_limited |
| Requests per minute, per IP address | zemoData | 429 rate_limited |
| Credits per day, per key | The key’s daily credit cap, if it has one | 402 credits.cap_reached |
| Records per request | 100 IDs per unlock |
422 validation |
Repeated failed authentication from one IP address blocks that address for a while, also with 429.
Limits use a sliding one-minute window.
Headers
Section titled “Headers”Every answer tells you where you stand:
RateLimit-Limit: 600RateLimit-Remaining: 597RateLimit-Reset: 42RateLimit-Reset is the number of seconds until the window has room again. A 429 also has
Retry-After (seconds). So does a 503.
Handling 429
Section titled “Handling 429”Wait for Retry-After seconds, then send the request again. Spending calls are safe to retry with the
same Idempotency-Key. Spread steady traffic out using RateLimit-Remaining rather than sending bursts.
"""Respect rate limits: read the RateLimit-* headers and retry after 429 (or 503) as told."""
import jsonimport osimport timeimport urllib.errorimport urllib.request
BASE = os.environ.get("ZEMO_API_BASE", "https://api.zemodata.com")HEADERS = {"Authorization": f"Bearer {os.environ['ZEMO_API_KEY']}"}
def call(request: urllib.request.Request, attempts: int = 5) -> dict: for attempt in range(attempts): try: with urllib.request.urlopen(request, timeout=30) as response: limit, left = response.headers["RateLimit-Limit"], response.headers["RateLimit-Remaining"] print(f"limit {limit}, remaining {left}, resets in {response.headers['RateLimit-Reset']} s") return json.load(response) except urllib.error.HTTPError as error: if error.code not in (429, 503) or attempt == attempts - 1: raise wait = int(error.headers.get("Retry-After", "1")) print(f"{error.code}: waiting {wait} s before trying again") time.sleep(wait) raise RuntimeError("unreachable")
me = call(urllib.request.Request(f"{BASE}/v1/whoami", headers=HEADERS))print("ok:", me["public_id"])// Respect rate limits: read the RateLimit-* headers and retry after 429 (or 503) as told.
const BASE = process.env.ZEMO_API_BASE ?? "https://api.zemodata.com";const sleep = (seconds) => new Promise((resolve) => setTimeout(resolve, seconds * 1000));
async function call(url, options, attempts = 5) { for (let attempt = 1; ; attempt += 1) { const response = await fetch(url, options); if (response.ok) { const h = response.headers; console.log("limit", h.get("RateLimit-Limit"), "remaining", h.get("RateLimit-Remaining"), "resets in", h.get("RateLimit-Reset"), "s"); return response.json(); } if (![429, 503].includes(response.status) || attempt === attempts) { throw new Error(`${response.status}: ${await response.text()}`); } const wait = Number(response.headers.get("Retry-After") ?? "1"); console.log(`${response.status}: waiting ${wait} s before trying again`); await sleep(wait); }}
const me = await call(`${BASE}/v1/whoami`, { headers: { Authorization: `Bearer ${process.env.ZEMO_API_KEY}` } });console.log("ok:", me.public_id);# Respect rate limits: read the RateLimit-* headers; on 429 (or 503) wait Retry-After seconds.set -euo pipefailBASE="${ZEMO_API_BASE:-https://api.zemodata.com}"
# --retry honours Retry-After on 429 and 503 responses.curl --silent --show-error --fail-with-body --retry 5 \ --dump-header - --output /dev/null \ -H "Authorization: Bearer $ZEMO_API_KEY" \ "$BASE/v1/whoami" | grep -i '^ratelimit-'