Access URL
Environment | URL |
---|---|
Sandbox | Public stream: wss://stream-glb.sim.hashkeydev.com/quote/ws/v2 |
Production | Public stream: wss://stream-glb.hashkey.com/quote/ws/v2 |
Heartbeat check
When a user's websocket client application successfully connects to HashKey websocket server, the client:
- is required to initiate a periodic heartbeat message (ping message) containing the sessionID and
- to ping the server every 10s, which is used to keep alive the connection
Auto-disconnection mechanism
- When the websocket server sends 3 Ping messages in a row, but neither Pong is returned, the websocket link will be automatically disconnected.
Ping message format
// request
{
"ping":1691473241907
}
Pong message format
// From Websocket Server
{
"pong":1691473283965
}
Data Structure
- Currently only support JSON format.
- Binary format is not yet available
Subscribe
Subscribe
{
"topic": "kline",
"event": "sub",
"params": {
"symbol": "ETHUSDT",
"klineType": "1m"
}
}
Subscription successful
{
"topic": "kline",
"event": "sub",
"params": {
"symbol": "BTCUSDT",
"klineType": "1m",
},
"code": "0",
"msg": "Success"
}
Subscription failed
{
"topic": "kline",
"event": "sub",
"params": {
"symbol": "BTCUSDT",
"klineType": "122m"
},
"code": "-100011",
"msg": "Parameter error!"
}
Unsubscribe
Unsubscribe
{
"topic":"kline",
"event":"cancel",
"params":{
"symbol": "BTCUSDT",
"klineType":"1m"
}
}
Unsubscribe result
{
"topic": "kline",
"event": "cancel",
"params": {
"symbol": "BTCUSDT",
"klineType": "1m",
},
"code": "0",
"msg": "Success"
}