Skip to main content

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

  1. 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

wss://ws.futurescw.com/perpum

Frequency Limit

None

Subscription Parameters

ParameterMandatoryTypeDescription
eventtrueStringSubscribe or unsubscribe. sub: subscribe; unsub: unsubscribe.
Note: This parameter is case-sensitive.
paramstrueJsonRequested parameter objects including:
-biztrueStringSpecifies the channel, e.g., "futures".
Note: Lowercase is recommended.
-typetrueStringDefines the function type, e.g., "candles_swap_utc".
Note: Lowercase is recommended.
-pairCodetrueStringThe 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.
-intervalTrueStringK-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

ParameterTypeDescription
bizStringSpecifies the channel, e.g., "futures".
typeStringDefines the function type, e.g., "candles_swap_utc".
resultbooleanIndicates whether the subscription or unsubscription is successful: true, false
channelStringSpecifies the action performed: subscribe or unsubscribe.
pairCodeStringBase currency of the instrument, i.e., BTC.
dataJsonData object, containing the following fields:
-BigDecimalCreation time (timestamp)
-BigDecimalOpening price of the interval.
-BigDecimalHighest price within the intterval.
-BigDecimalLowest price within the interval.
-BigDecimalClosing price of the interval.
-BigDecimalTrading volume (in base currency)
intervalStringK-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'},....