Skip to main content
Version: Next

WebSocket Connection Guide

Connection Addresses

ModuleWebSocket AddressDescription
Spot/api/v1/ws/klineReal-time K-line push
Futures/api/v1/futures/wsOrder book, Ticker, K-line push

General Rules

ItemDescription
ProtocolWebSocket (ws:// or wss://)
Data FormatJSON
Heartbeat TimeoutSpot: auto disconnect after 60 seconds of no message; Futures: auto disconnect after 70 seconds of no message
Recommended Heartbeat IntervalSend ping every 20 seconds

Connection Examples

Spot K-line:

wss://api9528mystks.mystonks.org/api/v1/ws/kline

Futures Market Data:

wss://api9528mystks.mystonks.org/api/v1/futures/ws

Heartbeat Mechanism

Heartbeat Request:

{"action": "ping"}

Spot Heartbeat Response:

{"event": "pong", "time": 1736163000000}

Futures Heartbeat Response:

{"event": "pong", "timestamp": 1736163000000}
Tip

Spot and Futures use different WebSocket connection addresses, heartbeat timeouts and some push structures also differ. Please refer to each module's documentation for details.