Skip to main content

Subscribe Index Price

API Description

This websocket allows querying the index price for a specified trading instrument.

Note: Index Price data is only available via Websocket API.

Precautions

None

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., "index_price"
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.

Response Parameters

ParameterTypeDescription
bizStringSpecifies the channel, e.g., "futures"
typeStringDefines the function type, e.g., "index_price"
resultbooleanIndicates whether the subscription or unsubscription was successful: true, false.
channelStringSpecifies the action performed: subscribe or unsubscribe.
pairCodeStringBase currency of the instrument, e.g., BTC.
dataJsonData object, containing the following fields:
-pBig DecimalIndex price.
-nStringBase currency of the instrument, e.g., btc

Subscription Example

The following Python code shows how to subscribe to index price 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",
"pairCode": "BTC",
"type": "index_price"}}
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 index price 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': 'index_price'}
{'biz': 'futures',
'pairCode': 'btc',
'data': {'p': 92383.3, 'n': 'btc'},
'type': 'index_price'},....