(Public WebSocket) Market Data WebSocket Interface
URL: /api/v1/public/ws
Description
01. When subscribing or unsubscribing, the server will validate the channel. For invalid channels, the server will respond with an error message, for example: {"type":"error","content":{"code":"INVALID_CONTRACT_ID""msg":"invalid contractId:100000001"}}
02. The message structure for subscribing and unsubscribing is: {"type": "subscribe", "channel": "ticker.10000001"}.
03. Ping-Pong Mechanism:
Server Ping (Heartbeat):
After a successful WebSocket connection, the server sends a Ping message at a fixed interval. The message body looks like: {"type":"ping","time":"1693208170000"}. The time field is the server's timestamp when the Ping was sent.
The client must respond with a Pong message upon receipt, with a body like: {"type":"pong","time":"1693208170000"}.
If the server doesn't receive a Pong response after 5 consecutive Pings, the server will terminate the connection.
Client Ping (Latency Measurement):
After a successful WebSocket connection, the client can also initiate a Ping message with a body like: {"type":"ping","time":"1693208170000"}. The time field is the client's timestamp when the Ping was sent.
The server will immediately respond with a Pong message, with a body like: {"type":"pong","time":"1693208170000"}. The time field in the Pong will match the time field in the client's Ping.
After a successful subscription, a full dataset is pushed once initially (depthType=SNAPSHOT), and subsequent pushes will be incremental updates (depthType=CHANGED).
Channel Explanation
Channel
Description
depth.{contractId}.{depth}
Subscribe to the order book of contract contractId with a depth of depth