Skip to main content

Klines Stream

Streaming candlestick (OHLCV) updates for a symbol and interval.

WebSocket URL: wss://stream.pipai.io/ws

Subscription

Subscribe:

{
"op": "subscribe",
"channel": "market.klines",
"params": { "symbol": "BTCUSDT", "interval": "1m" },
"req_id": "client-201"
}

Unsubscribe:

{
"op": "unsubscribe",
"channel": "market.klines",
"params": { "symbol": "BTCUSDT", "interval": "1m" },
"req_id": "client-202"
}

Subscription parameters

NameTypeMandatoryDescription
symbolstringYesTrading pair, uppercase, e.g. BTCUSDT.
intervalenumYesOne of 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M.

Payload

In-progress bar update:

{
"event": "kline",
"ts": 1745923200250,
"symbol": "BTCUSDT",
"interval": "1m",
"kline": {
"open_time": 1745923200000,
"close_time": 1745923259999,
"open": "67432.15",
"high": "67450.50",
"low": "67430.00",
"close": "67442.80",
"volume": "12.3421",
"quote_volume": "832104.55",
"trades": 142,
"taker_buy_volume": "6.8810",
"taker_buy_quote_volume": "464012.31",
"is_closed": false
}
}

Final close push for the bar:

{
"event": "kline",
"ts": 1745923260001,
"symbol": "BTCUSDT",
"interval": "1m",
"kline": {
"open_time": 1745923200000,
"close_time": 1745923259999,
"open": "67432.15",
"high": "67498.80",
"low": "67410.00",
"close": "67498.80",
"volume": "201.7710",
"quote_volume": "13612498.55",
"trades": 2014,
"taker_buy_volume": "112.4421",
"taker_buy_quote_volume": "7588321.42",
"is_closed": true
}
}

Payload fields

FieldTypeDescription
eventstringAlways "kline".
tsintegerServer push time, Unix milliseconds.
symbolstringTrading pair, uppercase.
intervalstringBar interval, echoed from the subscription.
klineobjectCandlestick payload (see below).

kline object

FieldTypeDescription
open_timeintegerBar open time, Unix milliseconds.
close_timeintegerBar close time, Unix milliseconds (last ms of the bar).
openstring (decimal)Open price.
highstring (decimal)High price so far in the bar.
lowstring (decimal)Low price so far in the bar.
closestring (decimal)Most recent traded price.
volumestring (decimal)Cumulative volume in base asset for the bar.
quote_volumestring (decimal)Cumulative volume in quote asset for the bar.
tradesintegerNumber of trades in the bar.
taker_buy_volumestring (decimal)Taker-buy volume in base asset.
taker_buy_quote_volumestring (decimal)Taker-buy volume in quote asset.
is_closedbooleantrue only on the final push for the bar; otherwise false.

Update frequency

Roughly every 250 ms while the bar is forming, plus a single final push with is_closed: true immediately after the bar closes. If no trade has occurred since the last push, an update may be skipped — never assume a strict cadence.

Reconnection

If the connection drops mid-bar, intermediate updates are lost but the next push (within ~250 ms of reconnect) carries the full cumulative state of the current bar, so consumers are self-healing for in-progress bars.

For closed bars that may have been missed during the disconnect, backfill with GET /v1/market/klines?symbol=...&interval=...&startTime=<last_known_close_time>.