WebSocket

πŸ“˜ General Overview

WebSocket is a modern HTML5 protocol that supports full-duplex communication between the client and the server. Unlike traditional polling or HTTP requests, WebSocket only requires a single handshake to establish a persistent connection, enabling efficient real-time data transfer.

βœ… Advantages

  • Extremely lightweight headers (~2 bytes)

  • Bi-directional communication: server and client can both initiate messages

  • No repeated TCP connectionsβ€”saves server resources and bandwidth

  • Highly recommended for real-time market data and order book depth

🌐 Connection Info

  • WebSocket URL: wss://ws.coinlocally.com/kline-api/ws

  • Compression: Binary data is compressed using Gzip β€” clients must decompress accordingly.

πŸ«€ Heartbeat (Ping/Pong)

To maintain connection stability:

  • The server sends a ping message every 10 seconds.

  • The client should immediately respond with a pong message.

  • The server does not enforce one-to-one verification, but may close the connection if no pong is received.

Ping Message (Server β†’ Client)

Pong Message (Client β†’ Server)


πŸ“‘ Command Format

πŸ”„ Subscribe & Unsubscribe

Command
Channel
Description

sub

market_$symbol_depth_step0

Subscribe to order book depth

unsub

market_$symbol_depth_step0

Unsubscribe from order book depth

sub

market_$symbol_trade_ticker

Subscribe to real-time trades

unsub

market_$symbol_trade_ticker

Unsubscribe from real-time trades

sub

market_$symbol_ticker

Subscribe to 24h market ticker

unsub

market_$symbol_ticker

Unsubscribe from 24h market ticker

sub

market_$symbol_kline_1min

Subscribe to 1-minute kline

req

market_$symbol_kline_1month

Request 1-month historical kline


πŸ“₯ Subscription Examples

πŸ“Š Depth (Order Book)

Subscribe Message

Response Payload


πŸ“ˆ Real-Time Trade

Subscribe Message

Response Payload


πŸ“‰ Kline (Candlestick Data)

Subscribe Message

Response Payload

πŸ“Š Market Ticker (24h)

Subscribe Message

Response Payload


πŸ“€ Request Historical Data

πŸ•° Historical Kline

Request Message

Response Payload


🧾 Historical Trades

Request Message

Response Payload

Last updated