Subscribe K-line(UTC+0)
API Description
This Websocket API provides K-line data for a specified instrument, including the timestamp, high price, low price, open price, close price and trading volume. Each candle is timestamped according to the UTC+0 time zone.
Note: K-line(UTC+0) data is only available via Websocket API.
Precautions
- Each candle is timestamped according to the UTC+0 time zone.
Authentication
This is a public websocket and does not require authentication. For details on using the Websocket API, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Public Interface.
Websocket URL
Frequency Limit
None
Subscription Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| event | true | String | Subscribe or unsubscribe. sub: subscribe; unsub: unsubscribe. Note: This parameter is case-sensitive. |
| params | true | Json | Requested parameter objects including: |
| -biz | true | String | Specifies the channel, e.g., "futures". Note: Lowercase is recommended. |
| -type | true | String | Defines the function type, e.g., "candles_swap_utc". Note: Lowercase is recommended. |
| -pairCode | true | String | The base currency of the instrument. (e.g., BTC or btc). This parameter is case-insensitive. Note: For instruments that start with numbers (e.g., 1000PEPE), both uppercase and lowercase formats are valid. |
| -interval | True | String | K-line interval, represented as: "1" (1 min), "3" (3 min), "5" (5 min), "15" (15 min), "30" (30 min), "1H" (1 hour), "4H" (4 hours), "1D" (1 day), "1W" (1 week), "1M" (1 month). Note: This parameter is case-insensitive. Both 1H and 1h are valid. |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| biz | String | Specifies the channel, e.g., "futures". |
| type | String | Defines the function type, e.g., "candles_swap_utc". |
| result | boolean | Indicates whether the subscription or unsubscription is successful: true, false |
| channel | String | Specifies the action performed: subscribe or unsubscribe. |
| pairCode | String | Base currency of the instrument, i.e., BTC. |
| data | Json | Data object, containing the following fields: |
| - | BigDecimal | Creation time (timestamp) |
| - | BigDecimal | Opening price of the interval. |
| - | BigDecimal | Highest price within the intterval. |
| - | BigDecimal | Lowest price within the interval. |
| - | BigDecimal | Closing price of the interval. |
| - | BigDecimal | Trading volume (in base currency) |
| interval | String | K-line interval, represented as: "1" (1 min), "3" (3 min), "5" (5 min), "15" (15 min), "30" (30 min), "1H" (1 hour), "4H" (4 hours), "1D" (1 day), "1W" (1 week), "1M" (1 month). |
Subscription Example
The following Python code shows how to subscribe to K-line(UTC+0) data for "BTC".
Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Public Interface.
subscription_params = { "event": "sub",
"params": {
"biz": "futures",
"interval":"1",
"pairCode": "BTC",
"type": "candles_swap_utc"}}
url = "wss://ws.futurescw.com/perpum"
FuturesWebsocketPublic(url, subscription_params) #function FuturesWebsocketPublic() is defined in section (Introduction > Authentication & Code Snippet > Futures > Websocket Public Interface)
Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Public Interface.
Response Example
The Websocket subscription will keep updating the K-line(UTC+0) data in real-time. For brevity, only the initial response for python subscrption is provided below:
{'biz': 'futures',
'pairCode': 'BTC',
'data': {'result': True},
'channel': 'subscribe',
'type': 'candles_swap_utc'}
{'biz': 'futures',
'pairCode': 'BTC',
'data': ['1745495580000',
'92548.7',
'92548.7',
'92540.1',
'92544.6',
'21.729'],
'interval': '1',
'type': 'candles_swap_utc'},....