Chuyển tới nội dung chính

Rate Limiting

Cohost API áp dụng rate limiting để bảo vệ hệ thống.

Scope: Áp dụng cho cả Internal APIExternal API.
Khi thiết kế Integration nội bộ, nên coi đây là “baseline” và kết hợp với Error Handling để xử lý 429 đúng chuẩn.
Đối tác/OTA xem thêm: External API Guide.

Giới hạn mặc định

LoạiGiới hạn
Internal API100 requests / phút / user
External API60 requests / phút / API key

Response Headers

Mỗi response trả về headers thông tin rate limit:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1700000060

Khi vượt giới hạn

HTTP 429 Too Many Requests

{
"code": "RATE_LIMIT_EXCEEDED",
"message": "Rate limit exceeded. Try again in 30 seconds.",
"details": {
"retry_after_seconds": 30
}
}

Client nên support cả format cũ (detail) và format chuẩn (code, message, details). Xem thêm: guides/error-handling.

Best Practices

  • Cache response khi có thể
  • Implement exponential backoff khi gặp 429
  • Dùng bulk endpoints thay vì nhiều request đơn lẻ