Rate Limiting & Quotas

Understand rate limits and optimize your API usage

Overview

API requests are rate-limited based on your quota tier to ensure fair usage and system stability. Exceeding limits returns a 429 Too Many Requests error with retry information.

Quota Tiers

Starter (Free)

$0
Per Minute
60
Per Hour
1,000
Per Day
10,000
Active Requests
5
Max Budget Per Request $1,000
Monthly Budget Limit $5,000

Professional

POPULAR
$99/mo
Per Minute
120
Per Hour
5,000
Per Day
50,000
Active Requests
20
Max Budget Per Request $5,000
Monthly Budget Limit $25,000

Enterprise

$499/mo
Per Minute
300
Per Hour
15,000
Per Day
150,000
Active Requests
100
Max Budget Per Request $20,000
Monthly Budget Limit $100,000

Rate Limit Headers

Every API response includes rate limit information in the headers:

X-RateLimit-Limit: 120        # Total requests allowed per window
X-RateLimit-Remaining: 115    # Requests remaining in current window
X-RateLimit-Reset: 1697558400 # Unix timestamp when limit resets

Handling Rate Limits

When you exceed rate limits, the API returns a 429 Too Many Requests response:

{
  "success": false,
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Rate limit exceeded. Retry after 45 seconds.",
    "retry_after": 45
  }
}

Example: Exponential Backoff (Python)

import time
import requests

def make_request_with_retry(url, headers, max_retries=3):
    for attempt in range(max_retries):
        response = requests.get(url, headers=headers)
        
        if response.status_code == 429:
            retry_after = response.json().get('error', {}).get('retry_after', 60)
            print(f"Rate limited. Retrying after {retry_after}s...")
            time.sleep(retry_after)
            continue
        
        return response.json()
    
    raise Exception("Max retries exceeded")

# Usage
data = make_request_with_retry(
    "https://opttab.com/api/v1/ai/budget-status",
    {"X-API-Key": "...", "X-API-Secret": "..."}
)

Optimization Tips

Cache Responses

Cache API responses that don't change frequently to reduce unnecessary requests.

Batch Operations

Use pagination parameters to retrieve multiple items in a single request instead of making individual calls.

Monitor Headers

Always check X-RateLimit-Remaining headers to avoid hitting limits.

Upgrade When Needed

If you're consistently hitting limits, upgrade to a higher tier for better performance.

Checking Your Quota

Use the Budget Status endpoint to monitor your current usage:

curl "https://opttab.com/api/v1/ai/budget-status" \
  -H "X-API-Key: opttab_abc123..." \
  -H "X-API-Secret: your-secret-here"

Example Response

{
  "success": true,
  "data": {
    "quota_tier": "Professional",
    "rate_limits": {
      "per_minute": 120,
      "per_hour": 5000,
      "per_day": 50000
    },
    "usage": {
      "requests_today": 1245,
      "requests_this_hour": 89,
      "requests_this_minute": 3
    },
    "remaining": {
      "today": 48755,
      "this_hour": 4911,
      "this_minute": 117
    }
  }
}