Rate Limits

The WebSocket API rate limits requests and connections by IP address.

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:

TypeLimit

Connections

10 active connections per IP address.

Requests

40 requests per 1 minute per IP address. Requests are counted, in total, across your active connections.

Best Practices

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

1. Consolidate feeds per subscribe/unsubscribe request

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

// Request -> Subscribe to feeds
{
    "type": "subscribe", 
    "feeds": ["<feed 1>", "<feed 2>", ...] //Subscribe to N feeds in 1 request
}

For example, if you want to subscribe to both the open orders and balances feeds:

// Request -> Subscribe to open orders and balances feeds
{
    "type": "subscribe", 
    "feeds": ["private.user.open-orders", "private.user.balances"]
}

2. Consolidate WebSocket consumption by connection

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.

Please note: To ensure optimal performance, sFOX recommends using a separate WebSocket connection for each feed "type" you subscribe to.

For example, consume market data and orders/account data in separate connections.

This segregation ensures that time-sensitive updates, such as balances or open-orders messages, are not impacted by high-frequency feeds like order books.

Last updated