Skip to main content

Subscribe Trade Data

API Description

This Websocket API provides trade data for a specified instrument, including contract size, direction, trade ID, timestamp, and price.

Note: Trade data data is available via both Resful and Websocket APIs. This page describes the Websocket API. For information on the RESTful API, please click here

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

The frequency limit for this subscription is 50 requests/2s per IP.

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., "fills". Note: Lowercase is recommended.
-pairCodetrueStringThe base currency of an 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".
typeStringFunction type e.g., "fills".
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:
-createdDateLongTimestamp when the trade occurred
-quantityBigDecimalOrder size in base currency
-pieceBigDecimalThe number of contracts
-priceBigDecimalThe executed transaction price.
-idLongPrimary key ID
-directionStringTrade direction: long, short.

Subscription Example

The following Python code shows how subscribe to the trade data.

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": "fills"}}
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 will keep updating the trade data in real time. For brevity, only one trade is shown below from Python subscription:

{'biz': 'futures',
'pairCode': 'BTC',
'data': {'result': True},
'channel': 'subscribe',
'type': 'fills'}
{'biz': 'futures',
'pairCode': 'BTC',
'data': [{'createdDate': 1740386094525,
'quantity': 0.007,
'piece': 7,
'price': 95449,
'id': 20742103698619397,
'direction': 'long'}],
'type': 'fills'},...........