Saltar al contenido principal

Límites de Tasa

La API de ArchiCore implementa límites de tasa para garantizar un uso justo.

Límites por Nivel

NivelSolicitudes/díaSolicitudes/minutoProyectos
Gratis100103
Pro10,00010025
EnterpriseIlimitado1,000Ilimitado

Headers de Límite de Tasa

Cada respuesta de la API incluye información sobre límites de tasa:

HTTP/1.1 200 OK
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640000000
HeaderDescripción
X-RateLimit-LimitSolicitudes máximas permitidas
X-RateLimit-RemainingSolicitudes restantes en la ventana
X-RateLimit-ResetTimestamp Unix cuando se reinicia el límite

Límite de Tasa Excedido

Cuando excedes el límite de tasa:

HTTP/1.1 429 Too Many Requests
Retry-After: 60
{
"success": false,
"error": "Límite de tasa excedido",
"code": "RATE_LIMIT_EXCEEDED",
"retryAfter": 60
}

Mejores Prácticas

1. Verificar Headers

Siempre verifica X-RateLimit-Remaining antes de hacer solicitudes:

async function makeRequest(url) {
const response = await fetch(url, { headers });

const remaining = response.headers.get('X-RateLimit-Remaining');
if (parseInt(remaining) < 10) {
console.warn('Límite de tasa bajo:', remaining);
}

return response.json();
}

2. Implementar Backoff Exponencial

async function requestWithRetry(url, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
const response = await fetch(url, { headers });

if (response.status !== 429) {
return response.json();
}

const retryAfter = response.headers.get('Retry-After') || 60;
await sleep(retryAfter * 1000 * Math.pow(2, i));
}

throw new Error('Máximo de reintentos excedido');
}

3. Cachear Respuestas

Cachea las respuestas para reducir llamadas a la API:

const cache = new Map();

async function getCached(key, fetchFn, ttl = 60000) {
const cached = cache.get(key);
if (cached && Date.now() - cached.timestamp < ttl) {
return cached.data;
}

const data = await fetchFn();
cache.set(key, { data, timestamp: Date.now() });
return data;
}

4. Operaciones por Lotes

Usa endpoints por lotes cuando estén disponibles:

// En lugar de múltiples solicitudes
for (const id of projectIds) {
await client.projects.get(id); // ❌ Múltiples solicitudes
}

// Usa endpoint por lotes
await client.projects.getBatch(projectIds); // ✓ Una sola solicitud

Aumentar Límites

¿Necesitas límites más altos? Actualiza a Pro o contáctanos para planes Enterprise.