Rate Limits
Token bucket per API key. Gratis, 1.000 req/menit untuk semua pemakai. Response menyertakan header limit real-time.
Policy
DYOGG pakai token bucket per API key.
Limit-nya sama untuk semua pemakai — DYOGG gratis dan tidak punya paket berbayar.
| Bucket | Refill | Burst |
|---|---|---|
| 1.000 | 1.000 / menit | 1.500 |
Butuh limit lebih tinggi untuk proyek komunitas? Ceritakan kebutuhanmu ke
support@dyogg.com — kami tinjau per kasus, tanpa biaya.
Header response
Setiap response (baik 200 maupun 4xx/5xx) menyertakan:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 863
X-RateLimit-Reset: 1690000000 # unix epoch (detik)
X-RateLimit-Reset-After: 42 # detik dari sekarang
Retry-After: 42 # hanya saat 429
Response 429
{
"error": {
"code": "rate_limited",
"message": "Rate limit exceeded — 1000/min bucket empty.",
"retry_after_seconds": 42
}
}
Endpoint dengan bucket khusus
Beberapa endpoint punya cap tambahan supaya tidak abuse:
| Endpoint | Extra limit |
|---|---|
POST /v1/scam-report | 5 report / UID pelapor / hari |
POST /v1/build-analyzer/analyze | 30 analisis / menit (CPU intensif) |
GET /v1/leaderboard/* | 60 req / menit (cache-heavy) |
POST /v1/damage-calculator/simulate | 10 sim / menit |
Best practice
- Cache di sisi client — response DYOGG punya
meta.ttl_secondsyang bisa kamu pakai untuk TTL cache lokal. - Batch request dengan endpoint bulk (
GET /v1/players?uids=…&game=…) — hemat quota + lebih cepat. - Exponential backoff untuk 429/5xx — mulai 1s, kali 2, cap 60s.
- Etag / If-None-Match didukung di endpoint archive — respect 304 untuk hemat bandwidth.
Circuit breaker
Kalau upstream data provider down, kami fail-open — response 503 dengan
Retry-After: 30. Jangan retry lebih cepat dari header suggestion, kalau tidak IP kamu di-throttle
sementara.
Contoh handle rate limit di TypeScript
async function withRetry<T>(fn: () => Promise<T>, maxAttempts = 5): Promise<T> {
for (let attempt = 0; attempt < maxAttempts; attempt++) {
try {
return await fn();
} catch (err: any) {
if (err.status !== 429 || attempt === maxAttempts - 1) throw err;
const wait = err.headers?.get("Retry-After") ?? 2 ** attempt;
await new Promise((r) => setTimeout(r, Number(wait) * 1000));
}
}
throw new Error("unreachable");
}