> ## Documentation Index
> Fetch the complete documentation index at: https://developer.wallbit.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Rate Limiting

> Understand API rate limits and how to handle them

## Rate Limits

The Wallbit API implements rate limiting to ensure fair usage and maintain service stability for all users.

### Current Limits

| Tier       | Requests per Minute | Requests per Day |
| ---------- | ------------------- | ---------------- |
| Standard   | 60                  | 10,000           |
| Pro        | 300                 | 100,000          |
| Enterprise | Custom              | Custom           |

<Info>
  Contact [support@wallbit.io](mailto:support@wallbit.io) to discuss Enterprise rate limits for high-volume use cases.
</Info>

### Rate Limit Headers

Every API response includes headers to help you track your rate limit status:

| Header                  | Description                          |
| ----------------------- | ------------------------------------ |
| `X-RateLimit-Limit`     | Maximum requests allowed per minute  |
| `X-RateLimit-Remaining` | Requests remaining in current window |
| `X-RateLimit-Reset`     | Unix timestamp when the limit resets |

### Example Response Headers

```http theme={null}
HTTP/1.1 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1640000000
```

### Handling Rate Limits

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

```json theme={null}
{
  "error": "Too Many Requests",
  "message": "Rate limit exceeded. Please wait before making more requests.",
  "retry_after": 30
}
```

### Best Practices

<AccordionGroup>
  <Accordion title="Implement Exponential Backoff" icon="clock">
    When you receive a 429 response, wait before retrying. Use exponential backoff to gradually increase wait times:

    ```javascript theme={null}
    async function requestWithRetry(url, options, maxRetries = 3) {
      for (let i = 0; i < maxRetries; i++) {
        const response = await fetch(url, options);
        
        if (response.status === 429) {
          const retryAfter = response.headers.get('Retry-After') || Math.pow(2, i);
          await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
          continue;
        }
        
        return response;
      }
      throw new Error('Max retries exceeded');
    }
    ```
  </Accordion>

  <Accordion title="Cache Responses" icon="database">
    Cache responses when possible to reduce API calls. Balance and asset data typically doesn't change every second.

    ```javascript theme={null}
    const cache = new Map();
    const CACHE_TTL = 30000; // 30 seconds

    async function getCachedBalance() {
      const cached = cache.get('balance');
      if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
        return cached.data;
      }
      
      const data = await fetchBalance();
      cache.set('balance', { data, timestamp: Date.now() });
      return data;
    }
    ```
  </Accordion>

  <Accordion title="Batch Requests" icon="layer-group">
    If you need multiple pieces of data, consider if there's a single endpoint that can provide all the information you need instead of making multiple requests.
  </Accordion>
</AccordionGroup>

### Rate Limit by Endpoint

Some endpoints may have different rate limits:

| Endpoint Category                      | Limit          |
| -------------------------------------- | -------------- |
| Read operations (GET)                  | Standard limit |
| Trade operations (POST /trades)        | 10 per minute  |
| Transfer operations (POST /operations) | 5 per minute   |

<Warning>
  Trade and transfer operations have lower limits to prevent accidental rapid-fire transactions.
</Warning>
