Skip to main content

KLines WebSocket

Streams real-time candle updates for a futures symbol at a chosen interval. Used to render live charts.

Event nameFETCH_CANDLESTICK_CS_PRO
ConnectionSee Connection.

Pair format — SYMBOL_INTERVAL

The pair field on the subscribe payload is SYMBOL_INTERVAL (with an underscore), where INTERVAL is in minutes. This is different from every other futures WebSocket (which use just SYMBOL).

PatternDescription
BTCUSDT_55-minute BTCUSDT candles
ETHUSDT_1515-minute ETHUSDT candles
DOGEUSDT_601-hour DOGEUSDT candles

Subscribe

import socketio

sio = socketio.Client()

BASE_URL = "wss://ws.coinswitch.co/"
NAMESPACE = "/exchange_2"
pair = "BTCUSDT_5" # SYMBOL_INTERVAL

sio.connect(
url=BASE_URL,
namespaces=[NAMESPACE],
transports="websocket",
socketio_path="/pro/realtime-rates-socket/futures/exchange_2",
wait=True,
wait_timeout=3600,
)

sio.emit(
"FETCH_CANDLESTICK_CS_PRO",
{"event": "subscribe", "pair": pair},
namespace=NAMESPACE,
)

@sio.on("FETCH_CANDLESTICK_CS_PRO", namespace=NAMESPACE)
def on_kline(data):
print("Kline:", data)

sio.wait()

Update payload

{
"o": "104562.7",
"h": "104588.5",
"l": "104535",
"c": "104558.7",
"v": "43.205",
"q": "1918381.4344",
"s": "BTCUSDT",
"i": "5",
"x": false,
"t": 1734343500000,
"T": 1734343799999,
"ts": 1734343543430
}
FieldTypeDescription
sstringSymbol.
istringInterval in minutes.
o / h / l / cstringOpen / high / low / close.
vstringBase-asset volume during the candle.
qstringQuote-asset (USDT) volume during the candle.
tintegerCandle start time (Unix ms).
TintegerCandle close time (Unix ms).
tsintegerTime of the most recent trade in this candle (Unix ms).
xbooleantrue if this candle is closed (final). false while it's still updating.

While a candle is open, x is false and you'll receive multiple updates as new trades print. When the interval boundary passes, you receive a final update with x = true, then the first update for the next candle.