Guide

Rate Limit

Limiti di richiesta, header e backoff sul 429

Limiti per piano

PianoLimite richiesteConcorrenzaAdatto a
Free10 richieste/min2 in paralleloTest e prototipazione
Pro100 richieste/min10 in paralleloApp in produzione
Enterprise1000 richieste/min50 in paralleloOperazioni su larga scala

Header di risposta

Ogni risposta include gli header di rate-limit:

X-RateLimit-Limit:     100
X-RateLimit-Remaining: 87
X-RateLimit-Reset:     1714137600

X-RateLimit-Reset è un timestamp Unix epoch.

Gestione del 429

Quando incontri 429 RATE_LIMIT_EXCEEDED, fai backoff fino all'epoch X-RateLimit-Reset — non riprovare alla cieca. Abbinalo al backoff esponenziale per errori transitori:

import httpx, time

def call(url: str, headers: dict, body: dict, max_attempts: int = 5):
    for attempt in range(max_attempts):
        r = httpx.post(url, headers=headers, json=body, timeout=60.0)
        if r.status_code != 429:
            r.raise_for_status()
            return r.json()
        reset = int(r.headers.get("X-RateLimit-Reset", "0"))
        wait = max(reset - int(time.time()), 2 ** attempt)
        time.sleep(wait)
    raise RuntimeError("rate-limited after retries")

Per i batch job, preferisci pochi batch più grandi a tanti piccoli — un batch di 50 URL conta come una richiesta sul rate limit, non cinquanta.