Bond

Checking network...

Futures WebSocket

Real-time market data streams and WebSocket API for perpetual futures trading.

Endpoints

WS API

wss://ws-fapi.bond.xyz/ws-fapi/v1

WS Streams

wss://fstream.bond.xyz/ws

Combined Streams

wss://fstream.bond.xyz/stream

WebSocket API (Request/Response)

The WebSocket API uses a request/response pattern for trading, market data queries, and account information. Connections are valid for 24 hours. The server sends a ping frame every 3 minutes; respond with pong within 10 minutes or the connection will be disconnected.

Place Order via WebSocket

{ "id": "order-1", "method": "order.place", "params": { "symbol": "BTCUSDT", "side": "BUY", "positionSide": "BOTH", "type": "LIMIT", "timeInForce": "GTC", "quantity": "0.001", "price": "40000", "timestamp": 1705311512994, "apiKey": "your_api_key", "signature": "your_signature" } }

Change Leverage

{ "id": "leverage-1", "method": "leverage", "params": { "symbol": "BTCUSDT", "leverage": 10, "timestamp": 1705311512994, "apiKey": "your_api_key", "signature": "your_signature" } }

Change Margin Type

{ "id": "margin-1", "method": "marginType", "params": { "symbol": "BTCUSDT", "marginType": "ISOLATED", "timestamp": 1705311512994, "apiKey": "your_api_key", "signature": "your_signature" } }

Get Account Status

{ "id": "account-1", "method": "account.status", "params": { "timestamp": 1705311512994, "apiKey": "your_api_key", "signature": "your_signature" } }

WebSocket Streams

Streams provide real-time push data. Access raw streams at /ws/<streamName> or combined streams at /stream?streams=<s1>/<s2>. All symbols for streams are lowercase. Connections valid for 24 hours. Server sends ping every 20 seconds.

Subscribe / Unsubscribe

// Subscribe {"method":"SUBSCRIBE","params":["btcusdt@aggTrade","btcusdt@depth"],"id":1} // Unsubscribe {"method":"UNSUBSCRIBE","params":["btcusdt@depth"],"id":312} // List subscriptions {"method":"LIST_SUBSCRIPTIONS","id":3}

Depth Stream

Stream Name: <symbol>@depth or <symbol>@depth@100ms

{ "e": "depthUpdate", "E": 1672515782136, "s": "BNBBTC", "U": 157, "u": 160, "b": [["0.0024", "10"]], "a": [["0.0026", "100"]] }

Managing a Local Order Book

1. Open a stream connection to the depth stream for your symbol.

2. Buffer events received. Note the U of the first event.

3. Get a depth snapshot from the REST API (/fapi/v1/depth).

4. If snapshot lastUpdateId is less than U from step 2, retry snapshot.

5. Discard buffered events where u <= snapshot lastUpdateId.

6. Apply remaining events to local book. For each price level, set new quantity (remove if zero).

WebSocket Limits

Incoming messages

5 per second max

Max streams per connection

1024

Connection limit

300 per 5 minutes per IP

Session duration

24 hours

Handshake weight

5 (shared with REST)

Rate Limits

Rate limits are shared between REST API and WebSocket API. Monitor the rateLimits field in WebSocket responses. WebSocket handshake costs 5 weight. Ping/pong frame limit is 5 per second maximum.