Limites de Taxa
A API ArchiCore implementa limites de taxa para garantir uso justo.
Limites por Nível
| Nível | Requisições/dia | Requisições/minuto | Projetos |
|---|---|---|---|
| Grátis | 100 | 10 | 3 |
| Pro | 10.000 | 100 | 25 |
| Enterprise | Ilimitado | 1.000 | Ilimitado |
Cabeçalhos de Limite de Taxa
Cada resposta da API inclui informações de limite de taxa:
HTTP/1.1 200 OK
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640000000
| Cabeçalho | Descrição |
|---|---|
X-RateLimit-Limit | Requisições máximas permitidas |
X-RateLimit-Remaining | Requisições restantes na janela |
X-RateLimit-Reset | Timestamp Unix de reset do limite |
Limite de Taxa Excedido
Quando você excede o limite de taxa:
HTTP/1.1 429 Too Many Requests
Retry-After: 60
{
"success": false,
"error": "Limite de taxa excedido",
"code": "RATE_LIMIT_EXCEEDED",
"retryAfter": 60
}
Melhores Práticas
1. Verificar Cabeçalhos
Sempre verifique X-RateLimit-Remaining antes das requisições:
async function makeRequest(url) {
const response = await fetch(url, { headers });
const remaining = response.headers.get('X-RateLimit-Remaining');
if (parseInt(remaining) < 10) {
console.warn('Limite de taxa baixo:', 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 tentativas excedido');
}
3. Cachear Respostas
Cache respostas para reduzir chamadas à 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. Operações em Lote
Use endpoints em lote quando disponíveis:
// Em vez de múltiplas requisições
for (const id of projectIds) {
await client.projects.get(id); // ❌ Múltiplas requisições
}
// Use endpoint em lote
await client.projects.getBatch(projectIds); // ✓ Uma requisição
Aumentar Limites
Precisa de limites maiores? Faça upgrade para Pro ou entre em contato para planos Enterprise.