> For the complete documentation index, see [llms.txt](https://docs.sfox.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sfox.com/websocket-api/rate-limits.md).

# Rate Limits

Connecting to the WebSocket API

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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sfox.com/websocket-api/rate-limits.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
