# Rate Limits

The WebSocket API rate limits requests and connections by IP address.&#x20;

If you exceed a rate limit, an error is thrown and your requests will be blocked for 2 minutes.

Rate limits for the WebSocket API are as follows:

<table><thead><tr><th width="147">Type</th><th>Limit</th></tr></thead><tbody><tr><td><strong>Connections</strong></td><td><strong>10 active connections</strong> per IP address.</td></tr><tr><td><strong>Requests</strong></td><td><strong>40 requests per 1 minute</strong> per IP address. Requests are counted, in total, across your active connections.</td></tr></tbody></table>

## Best Practices

To avoid rate limiting, sFOX recommends following these best practices:

#### 1. Consolidate feeds per [subscribe/unsubscribe request](/websocket-api/subscribing-and-unsubscribing.md)

Subscribe/unsubscribe to multiple WebSocket feeds in a single request rather than sending subscribe requests per WebSocket feed.

<pre class="language-json" data-overflow="wrap"><code class="lang-json"><strong>// Request -> Subscribe to feeds
</strong>{
    "type": "subscribe", 
    "feeds": ["&#x3C;feed 1>", "&#x3C;feed 2>", ...] //Subscribe to N feeds in 1 request
}
</code></pre>

For example, if you want to subscribe to both the [open orders](/websocket-api/orders-and-account-data/orders.md) and [balances](/websocket-api/orders-and-account-data/balances.md) feeds:

<pre class="language-json"><code class="lang-json"><strong>// Request -> Subscribe to open orders and balances feeds
</strong>{
    "type": "subscribe", 
    "feeds": ["private.user.open-orders", "private.user.balances"]
}
</code></pre>

#### 2. Consolidate WebSocket consumption by [connection](/websocket-api/connecting.md)

Consuming the same data across >1 connection will result in duplicate requests. For example, if you want consume the BTC/USD order book, do so in a single connection.

{% hint style="info" %}
Please note: To ensure optimal performance, sFOX recommends using a separate WebSocket connection for each feed "type" you subscribe to.&#x20;

For example, consume [market data](/websocket-api/market-data.md) and [orders/account data](/websocket-api/orders-and-account-data.md) in separate connections.

This segregation ensures that time-sensitive updates, such as [balances](/websocket-api/orders-and-account-data/balances.md) or [open-orders](/websocket-api/orders-and-account-data/orders.md) messages, are not impacted by high-frequency feeds like [order books](/websocket-api/market-data/order-book.md).
{% endhint %}


---

# 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.sfox.com/websocket-api/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.
