Skip to content

Rate 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.

Every answer tells you where you stand:

RateLimit-Limit: 600
RateLimit-Remaining: 597
RateLimit-Reset: 42

RateLimit-Reset is the number of seconds until the window has room again. A 429 also has Retry-After (seconds). So does a 503.

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.

python/rate_limits.py
"""Respect rate limits: read the RateLimit-* headers and retry after 429 (or 503) as told."""
import json
import os
import time
import urllib.error
import 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"])