API Reference

Public Stream (WS v2)

Access URL

EnvironmentURL
SandboxPublic stream: wss://stream-glb.sim.hashkeydev.com/quote/ws/v2
ProductionPublic 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 channelID and
  • to ping the server every 10s, which is used to keep alive the connection

Auto-disconnection mechanism (Only for Private Stream)

  • The websocket server will send Ping messages periodically, and we suggest the user returned pong periodically (each 5 minutes), otherwise 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" }