WebSocket
General
Websocket
is a new HTML5 Protocol. It achieves full-duplex data transmission between the client and the server, allowing data to be transferred effectively in both directions. With just only one handshake, the connection between the client and the server is established. The server will then be able to push data to the client according to preset rules. Its advantages include:
The
WebSocket
request header for data transmission between client and server is approximately 2 bytes onlyEither the client or server can initiate a data transmission
As there is no need to create and delete TCP connection repeatedly, it saves resources for both bandwidth and server
We strongly recommend developers to use WebSocket API to retrieve market data and order book depth.
Ws information
url: wss://ws.exchange1.com/kline-api/ws
The returned data will be binary compressed (users need to decompress it through the Gzip algorithm)
heartbeat
The server actively pushes ping messages every 10 seconds, and the client can decide whether to process it after receiving it (the server does not perform strict one-to-one verification and time verification on the client's Pong reply). To ensure the validity of the link, it is recommended that the client immediately reply in Pong format after receiving the ping message from the server. Format of ping message that is sent by Server is: {"ping": timestamp (seconds)} pong message format that is replied by client is : {"pong": timestamp (seconds)} Example: {"pong":1694416595}
Command Format
sub
market_$symbol_depth_step0
Subscribe depth
描述
unsub
market_$symbol_depth_step0
Unsubscribe depth
币对名称
sub
market_$symbol_trade_ticker
Subscribe to real-time trade
base货币
unsub
market_$symbol_trade_ticker
Unsubscribe real-time trade
计价货币
sub
market_$symbol_ticker
Subscribe to 24h market data
价格精度
unsub
market_$symbol_ticker
Unsubscribe 24h market data
数量精度
sub
market_$symbol_kline_1min
Subscribe to 1min k-line information
reg
market_$symbol_kline_1month
Request 1 month historical bar record
Heartbeat
Every once in a while, the server will send a PING
message. The client needs to reply to the PONG
message, otherwise the server will close the connection.
ping
pong
Subscription Full Depth
Subscription message structure
Payload
Subscription Real Time Trade
Subscription message structure
Payload
Subscription Kline Market
Subscription message structure
Payload
Subscription Market Tickers
Subscription message structure
Payload
Request Kline History Data
Subscription message structure
Payload
Request History Trade
Subscription message structure
Payload
Last updated