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
| Name | Type | Mandatory | Description |
|---|---|---|---|
symbol | string | Yes | Trading pair, uppercase, e.g. BTCUSDT. |
interval | enum | Yes | One 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
| Field | Type | Description |
|---|---|---|
event | string | Always "kline". |
ts | integer | Server push time, Unix milliseconds. |
symbol | string | Trading pair, uppercase. |
interval | string | Bar interval, echoed from the subscription. |
kline | object | Candlestick payload (see below). |
kline object
| Field | Type | Description |
|---|---|---|
open_time | integer | Bar open time, Unix milliseconds. |
close_time | integer | Bar close time, Unix milliseconds (last ms of the bar). |
open | string (decimal) | Open price. |
high | string (decimal) | High price so far in the bar. |
low | string (decimal) | Low price so far in the bar. |
close | string (decimal) | Most recent traded price. |
volume | string (decimal) | Cumulative volume in base asset for the bar. |
quote_volume | string (decimal) | Cumulative volume in quote asset for the bar. |
trades | integer | Number of trades in the bar. |
taker_buy_volume | string (decimal) | Taker-buy volume in base asset. |
taker_buy_quote_volume | string (decimal) | Taker-buy volume in quote asset. |
is_closed | boolean | true 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>.