Cafora Docs
Developer

Rate Limits

Understand API rate limits and how to work within them.

The Cafora Host API enforces rate limits to ensure fair usage and service stability.

Rate Limit Tiers

Endpoint TypeRate Limit
Read operationsHigher limit (info queries)
Write operationsModerate limit (actions)
Backup operationsLower limit (resource-intensive)

Exact rate limits are documented in the API response headers. Always check X-RateLimit-Remaining in responses.

Rate Limit Headers

Every API response includes rate limit information:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1642000000
  • Limit: Total requests allowed in the window
  • Remaining: Requests remaining in the current window
  • Reset: Unix timestamp when the limit resets

Handling Rate Limits

429 Too Many Requests

When you exceed the rate limit, the API returns a 429 status code. Your application should:

  1. Read the Retry-After header for the wait time
  2. Wait before making additional requests
  3. Implement exponential backoff for retries
import time
import requests

def api_request(url, headers):
    response = requests.get(url, headers=headers)
    if response.status_code == 429:
        retry_after = int(response.headers.get("Retry-After", 5))
        print(f"Rate limited. Waiting {retry_after}s")
        time.sleep(retry_after)
        return api_request(url, headers)
    return response

Best Practices

  • Cache responses when possible to reduce API calls
  • Use webhooks instead of polling for status changes
  • Batch operations when the API supports it
  • Monitor X-RateLimit-Remaining proactively

On this page