WebSocket
General
WebSocket is a modern HTML5 protocol that enables full-duplex data transmission between the client and the server, allowing data to be transferred effectively in both directions. With a single handshake, the connection is established, allowing the server to push data to the client according to preset rules. Its advantages include:
The WebSocket request header for data transmission between the client and server is approximately 2 bytes only.
Either the client or server can initiate data transmission.
No need to repeatedly create and delete TCP connections, saving resources for both bandwidth and server.
We strongly recommend developers to use the WebSocket API to retrieve market data and order book depth.
WebSocket Information
URL: wss://ws.fokawa.com/kline-api/ws
The returned data will be binary compressed (users need to decompress it using the Gzip algorithm).
Heartbeat
The server actively pushes ping messages every 10 seconds. The client should reply with a pong message to maintain the connection. The server does not strictly verify the client's pong replies. To ensure the link's validity, the client should immediately reply in Pong format upon receiving a ping message from the server.
Ping message format sent by the server:
{"ping": timestamp (seconds)}
Pong message format replied by the client:
{"pong": timestamp (seconds)}
Example:
{"pong": 1694416595}
Command Format
Subscribe Depth:
sub market_$symbol_depth_step0
Unsubscribe Depth:
unsub market_$symbol_depth_step0
Subscribe to Real-Time Trade:
sub market_$symbol_trade_ticker
Unsubscribe Real-Time Trade:
unsub market_$symbol_trade_ticker
Subscribe to 24h Market Data:
sub market_$symbol_ticker
Unsubscribe 24h Market Data:
unsub market_$symbol_ticker
Subscribe to 1min K-line Information:
sub market_$symbol_kline_1min
Request 1 Month Historical Bar Record:
reg market_$symbol_kline_1month
Heartbeat Example
Ping:
Pong:
Subscription Messages
Full Depth Subscription Message:
Full Depth Payload:
Real-Time Trade Subscription Message:
Real-Time Trade Payload:
Kline Market Subscription Message:
Kline Market Payload:
Market Tickers Subscription Message:
Market Tickers Payload:
Request Kline History Data
Subscription Message Structure:
Payload:
Request History Trade
Subscription Message Structure:
Payload:
Last updated