K Line
K Line is used to subscribe to real-time updates for the candlestick (Kline) data of a specific trading pair on our platform.
Information
Update Speed: 2000ms
Initial Limit: 50 data points
Message Structure
Send Message
type: Specifies the type of WebSocket message.
- Type: String
- Value: "subscribe"
channel: Indicates the type of data to subscribe to (e.g., Kline updates).
- Type: String
- Value: "kline"
id: A unique identifier for the subscription request.
- Type: String
- Value: A randomly generated string or any unique identifier.
symbol: Specifies the trading pair for which the subscriber wants to receive Kline updates.
- Type: String
- Example: "WBTCUSDT"
interval: The time interval for each candlestick in the Kline data.
- Type: String
- Examples: "1m", "5m", "15m", "30m", "1h", "4h", "1h".
Subscribe Example
{ "type": "subscribe", "channel": "kline", "id": "random string", "symbol": "WBTCUSDT", "interval": "1m" }
Unsubscribe Example
{ "type": "unsubscribe", "channel": "kline", "id": "random string", "symbol": "WBTCUSDT", "interval": "1m" }
Initial Message
id: A unique identifier for the message, used to match responses to specific requests.
- Type: String
- Value: "random string"
type: Specifies the type of WebSocket message.
- Type: String
- Value: "init"
channel: Indicates the type of data to subscribe to (e.g., Kline updates).
- Type: String
- Value: "kline"
symbol: Specifies the trading pair for which the subscriber wants to receive Kline updates.
- Type: String
- Example: "WBTCUSDT"
interval: The time interval for each candlestick in the Kline data.
- Type: String
- Examples: "1m", "5m", "15m", "30m", "1h", "4h", "1h".
timestamp: The timestamp when the response was generated.
- Type: Integer (UNIX timestamp in milliseconds)
- Examples: 1704696764925
data: Contains the actual Kline update information.
- openTime: The opening time of the candlestick.
- Type: Integer (UNIX timestamp in milliseconds)
- openPrice: The opening price of the candlestick.
- Type: String
- highPrice: The highest price reached during the candlestick's duration.
- Type: String
- lowPrice: The lowest price reached during the candlestick's duration.
- Type: String
- closePrice: The closing price of the candlestick.
- Type: String
- volume: The total traded volume during the candlestick's duration.
- Type: String
- trades: The number of trades executed during the candlestick's duration.
- Type: Integer
- closeTime: The closing time of the candlestick.
- Type: Integer (UNIX timestamp in milliseconds & UTC)
- quoteVolume: The total quoted volume during the candlestick's duration.
- Type: String
- takerBuyBaseVolume: The volume of the asset bought by takers during the candlestick's duration.
- Type: String
- takerBuyQuoteVolume: The quoted volume of the asset bought by takers during the candlestick's duration.
- Type: String
- openTime: The opening time of the candlestick.
Response Example
{
"error": false,
"id": "random string",
"type": "init",
"channel": "kline",
"symbol": "WBTCUSDT",
"interval": "1m",
"timestamp": 1704696764925,
"data": [
{
"openTime": 1704693780000,
"openPrice": "43616.78000000",
"highPrice": "43623.86000000",
"lowPrice": "43616.78000000",
"closePrice": "43623.86000000",
"volume": "0.14000000",
"trades": 2,
"closeTime": 1704693839999,
"quoteVolume": "6106.77400000",
"takerBuyBaseVolume": "0.14000000",
"takerBuyQuoteVolume": "0.00000000"
},
{
"openTime": 1704693840000,
"openPrice": "43625.47000000",
"highPrice": "43625.47000000",
"lowPrice": "43606.80000000",
"closePrice": "43616.05000000",
"volume": "0.13000000",
"trades": 3,
"closeTime": 1704693899999,
"quoteVolume": "5670.18410000",
"takerBuyBaseVolume": "0.11000000",
"takerBuyQuoteVolume": "872.13600000"
},
{
"openTime": 1704693900000,
"openPrice": "43621.10000000",
"highPrice": "43621.10000000",
"lowPrice": "43621.10000000",
"closePrice": "43621.10000000",
"volume": "0.09000000",
"trades": 1,
"closeTime": 1704693959999,
"quoteVolume": "3925.89900000",
"takerBuyBaseVolume": "0.09000000",
"takerBuyQuoteVolume": "0.00000000"
}
]
}
Update Message
- Type: Specifies the type of WebSocket message.
- Type: String
- Value: "update"
- Channel: Indicates the type of data to subscribe to (e.g., Kline updates).
- Type: String
- Value: "kline"
- Symbol: Specifies the trading pair for which the subscriber wants to receive Kline updates.
- Type: String
- Example: "WBTCUSDT"
- Interval: The time interval for each candlestick in the Kline data.
- Type: String
- Examples: "1m", "5m", "15m", "30m", "1h", "4h", "1h".
- Data: Contains the actual Kline update information.
- Open Time: The opening time of the candlestick.
- Type: Integer (UNIX timestamp in milliseconds & UTC)
- Open Price: The opening price of the candlestick.
- Type: String
- High Price: The highest price reached during the candlestick's duration.
- Type: String
- Low Price: The lowest price reached during the candlestick's duration.
- Type: String
- Close Price: The closing price of the candlestick.
- Type: String
- Volume: The total traded volume during the candlestick's duration.
- Type: String
- Trades: The number of trades executed during the candlestick's duration.
- Type: Integer
- Close Time: The closing time of the candlestick.
- Type: Integer (UNIX timestamp in milliseconds)
- Quote Volume: The total quoted volume during the candlestick's duration.
- Type: String
- Taker Buy Base Volume: The volume of the asset bought by takers during the candlestick's duration.
- Type: String
- Taker Buy Quote Volume: The quoted volume of the asset bought by takers during the candlestick's duration.
- Type: String
- Open Time: The opening time of the candlestick.
Update Example
{
"type": "update",
"channel": "kline",
"symbol": "WBTCUSDT",
"interval": "1m",
"data": {
"openTime": 1700813460000,
"openPrice": "33749.79000000",
"highPrice": "33749.79000000",
"lowPrice": "33749.79000000",
"closePrice": "33749.79000000",
"volume": "0.00000000",
"trades": 0,
"closeTime": 1700813519999,
"quoteVolume": "0.00000000",
"takerBuyBaseVolume": "0.00000000",
"takerBuyQuoteVolume": "0.00000000"
}
}