Ir al contenido

Rate limits

Valores confirmados en el backend (payments/settings.py, clave REST_FRAMEWORK.DEFAULT_THROTTLE_RATES):

ThrottleLímiteAlcance
anon — peticiones por día2000/díaPeticiones anónimas y las autenticadas por X-Device-Id.
anon_minute — peticiones por minuto60/minPeticiones generales.
anon_minute_strict — minuto estricto15/minEndpoints críticos marcados con @custom_throttle_strict.
anon_day_strict — día estricto200/díaEndpoints críticos.
user — usuarios autenticados2000/díaPara 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.

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 Requests
Retry-After: 42
  • 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.
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.');
}