Rate limiting
Pickwise Public API aplica rate limiting por API Key para proteger la infraestructura y asegurar uso justo. Toda request cuenta contra el contador de tu key.
Límites actuales
Sección titulada «Límites actuales»| Ventana | Límite por defecto |
|---|---|
| Por minuto | 60 requests |
| Por día | 10 000 requests |
- La ventana por minuto es sliding — no se resetea cada minuto exacto, sino que cuenta las últimas 60 segundos.
- El límite aplica a todos los endpoints de la API (batch y single cuentan igual por request).
- Si necesitás límites más altos, contactá a soporte@lubee.com.ar.
Headers en cada respuesta
Sección titulada «Headers en cada respuesta»Toda respuesta (exitosa o no) incluye headers informativos para que puedas monitorear el uso:
X-RateLimit-Limit: 60X-RateLimit-Remaining: 45X-RateLimit-Reset: 1709827200| Header | Significado |
|---|---|
X-RateLimit-Limit | Límite máximo por minuto asignado a tu key. |
X-RateLimit-Remaining | Requests restantes en la ventana actual. |
X-RateLimit-Reset | Timestamp Unix (segundos) en que se resetea el contador. |
Úsalos para reducir el ritmo proactivamente antes de llegar al límite.
Error 429
Sección titulada «Error 429»Cuando excedés el límite, recibís:
HTTP/1.1 429 Too Many RequestsContent-Type: application/jsonRetry-After: 45{ "success": false, "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Límite de requests excedido (60/min). Reintente en 45 segundos.", "retryAfter": 45 }, "requestId": "550e8400-e29b-41d4-a716-446655440000"}retryAfteren segundos: cuánto esperar antes de reintentar.- Respetá ese valor. Reintentar antes solo suma más requests al contador.
Backoff exponencial
Sección titulada «Backoff exponencial»Cuando recibís 429 (o errores 5xx), implementá retry con backoff exponencial. Usá retryAfter como primera opción; si no está presente, usá tu propio cálculo.
# No hay manera robusta de hacer backoff en curl puro — usar wrapper en shellfor i in 1 2 3; do response=$(curl -sS -w "\n%{http_code}" \ -X POST https://api-{CLIENTE}.pickwise.com.ar/api/v1/public/products \ -H "Authorization: Bearer pk_live_xxxx" \ -H "Content-Type: application/json" \ -d '{...}') code=$(echo "$response" | tail -1) if [ "$code" != "429" ] && [ "${code:0:1}" != "5" ]; then echo "$response" | head -n -1 break fi sleep $((2 ** i))doneasync function callWithBackoff(url, init, maxRetries = 5) { for (let attempt = 0; attempt < maxRetries; attempt++) { const res = await fetch(url, init);
if (res.status === 429) { const body = await res.json().catch(() => ({})); const retryAfter = body?.error?.retryAfter ?? Number(res.headers.get('Retry-After')) ?? Math.pow(2, attempt); await sleep(retryAfter * 1000); continue; }
if (res.status >= 500) { await sleep(Math.pow(2, attempt) * 1000); continue; }
return res; } throw new Error('Max retries exceeded');}
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
const res = await callWithBackoff( 'https://api-{CLIENTE}.pickwise.com.ar/api/v1/public/products', { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.PICKWISE_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ externalId: 'P1', sku: 'SKU1', name: 'Prod 1', stock: 10 }) });<?phpfunction callWithBackoff(string $url, array $payload, int $maxRetries = 5): string { for ($attempt = 0; $attempt < $maxRetries; $attempt++) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer ' . getenv('PICKWISE_API_KEY'), 'Content-Type: application/json' ]); $response = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch);
if ($code === 429) { $body = json_decode($response, true); $retryAfter = $body['error']['retryAfter'] ?? pow(2, $attempt); sleep($retryAfter); continue; }
if ($code >= 500) { sleep(pow(2, $attempt)); continue; }
return $response; } throw new Exception('Max retries exceeded');}Estrategias para minimizar 429
Sección titulada «Estrategias para minimizar 429»Aumentar el límite
Sección titulada «Aumentar el límite»Si tu volumen legítimo supera los 60 req/min (ej: sincronización inicial de un catálogo de 100k productos), contactanos a soporte@lubee.com.ar. Podemos:
- Subir el límite permanentemente para tu key.
- Aprobar un “burst” temporal para una ventana de migración.
- Sugerir el endpoint batch si todavía no lo estás usando.
Siguientes guías
Sección titulada «Siguientes guías» Manejo de errores 429 junto con otros códigos y su estrategia de retry.
Idempotencia Retry seguro con `X-Idempotency-Key`.