# Rate Limits & Quotas

Cubit enforces rate limits to ensure fair usage and API stability.

## Limits by Tier

| Tier             | Daily Limit | Burst (per minute) |
| ---------------- | ----------- | ------------------ |
| **Sandbox**      | 100         | 10                 |
| **Professional** | 5,000       | 100                |
| **Enterprise**   | Unlimited   | 1,000              |

## Checking Your Usage

### Via API

```python
from cubit import CubitClient

client = CubitClient("cubit_your_key")
info = client.me()

print(f"Tier: {info['tier']}")
print(f"Remaining: {info['rate_limit']['remaining']}")
```

### Via Response Headers

Every response includes rate limit headers:

```
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4847
X-RateLimit-Reset: 2026-01-25T00:00:00Z
```

## When You're Rate Limited

### HTTP Response

```http
HTTP/1.1 429 Too Many Requests
Retry-After: 3600
Content-Type: application/json

{
  "error": "rate_limit_exceeded",
  "message": "Rate limit exceeded. Please wait or upgrade your plan.",
  "details": {
    "resets_at": "2026-01-25T00:00:00Z"
  }
}
```

### SDK Exception

```python
from cubit import CubitClient, RateLimitError

client = CubitClient("cubit_your_key")

try:
    results = client.search_jobs("developer")
except RateLimitError as e:
    print(f"Rate limited!")
    print(f"Retry after: {e.retry_after} seconds")
```

## Best Practices

### 1. Cache Responses

Job profiles and skills don't change frequently. Cache them:

```python
import redis
import json

redis_client = redis.Redis()
CACHE_TTL = 3600 * 24  # 24 hours

def get_job_cached(client, soc_code):
    cache_key = f"cubit:job:{soc_code}"
    
    cached = redis_client.get(cache_key)
    if cached:
        return json.loads(cached)
    
    job = client.get_job(soc_code)
    redis_client.setex(cache_key, CACHE_TTL, json.dumps(job))
    return job
```

### 2. Use Batch Operations (Enterprise)

Instead of individual requests:

```python
# Inefficient: 100 separate requests
for soc in soc_codes:
    job = client.get_job(soc)

# Efficient: 1 batch request
batch = client.batch_lookup(soc_codes)
```

### 3. Implement Exponential Backoff

```python
import time
from cubit import RateLimitError

def api_call_with_backoff(func, *args, max_retries=3):
    for attempt in range(max_retries):
        try:
            return func(*args)
        except RateLimitError as e:
            if attempt < max_retries - 1:
                wait = e.retry_after or (2 ** attempt * 60)
                print(f"Rate limited. Waiting {wait}s...")
                time.sleep(wait)
            else:
                raise
```

### 4. Spread Requests Over Time

For bulk operations, pace your requests:

```python
import time

def bulk_fetch(client, soc_codes, requests_per_minute=50):
    delay = 60 / requests_per_minute
    results = []
    
    for soc in soc_codes:
        results.append(client.get_job(soc))
        time.sleep(delay)
    
    return results
```

## What Counts as a Request

| Action                  | Request Count        |
| ----------------------- | -------------------- |
| Single job lookup       | 1                    |
| Single search query     | 1                    |
| Batch lookup (500 jobs) | 1                    |
| Custom score (100 jobs) | 1                    |
| Health check            | 0 (no auth required) |

## Quotas That Reset

| Quota               | Reset Schedule          |
| ------------------- | ----------------------- |
| Daily request limit | Midnight UTC            |
| Burst limit         | Rolling 1-minute window |

## Need Higher Limits?

### Professional to Enterprise

Enterprise tier offers unlimited daily requests plus batch operations.

[Upgrade to Enterprise](https://cubit.maidenlabs.tools/pricing)

### Custom Arrangements

For very high-volume use cases, contact us:

**Email:** <enterprise@maidenlabs.tools>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.maidenlabs.tools/resources/rate-limits.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
