Rate limits
Límites por defecto
Sección titulada «Límites por defecto»Valores confirmados en el backend (payments/settings.py, clave REST_FRAMEWORK.DEFAULT_THROTTLE_RATES):
| Throttle | Límite | Alcance |
|---|---|---|
anon — peticiones por día | 2000/día | Peticiones anónimas y las autenticadas por X-Device-Id. |
anon_minute — peticiones por minuto | 60/min | Peticiones generales. |
anon_minute_strict — minuto estricto | 15/min | Endpoints críticos marcados con @custom_throttle_strict. |
anon_day_strict — día estricto | 200/día | Endpoints críticos. |
user — usuarios autenticados | 2000/día | Para flows con sesión; no aplica al integrador vía X-Device-Id. |
Los límites son acumulativos: al superar cualquiera, recibirá HTTP 429 Too Many Requests.
Cabecera Retry-After
Sección titulada «Cabecera Retry-After»Cuando recibe HTTP 429, B4bit Pay incluye la cabecera Retry-After con el número de segundos que debe esperar antes de reintentar:
HTTP/1.1 429 Too Many RequestsRetry-After: 42Recomendaciones
Sección titulada «Recomendaciones»- Backoff exponencial — comience con el valor de
Retry-After, duplique en cada 429 consecutivo. - Jitter aleatorio — añada ±20% de variación para evitar thundering herd.
- Batchee consultas — agrupe
GET /orders/por rango en lugar de pedir órdenes individuales. - Prefiera webhooks a polling — los webhooks no consumen cuota.
Ejemplo de handler 429
Sección titulada «Ejemplo de handler 429»async function fetchWithBackoff(url, init, maxRetries = 5) { let delay = 1000; for (let i = 0; i < maxRetries; i++) { const res = await fetch(url, init); if (res.status !== 429) return res; const retryAfter = Number(res.headers.get('retry-after')) * 1000 || delay; const jitter = Math.floor(Math.random() * retryAfter * 0.2); await new Promise((r) => setTimeout(r, retryAfter + jitter)); delay *= 2; } throw new Error('Rate limit excedido tras reintentos.');}