Skip to main content

Subscribe Trades

API Description​

This Websocket interface provides real-time trade data for a specified instrument, including trade quantity, trade price, total trade amount, trade timestamp, and trade direction.

Note: Trades data is accessible via both RESTful and Websocket APIs. This page describes the Websock API. For information on the RESTful API, please please click here

Precautions​

  1. Currently, two methods are availabe for trades subscription. User should exercise caution while creating connection.

Method 1

Authentication​

This is a public Websocket and does not require authentication. For details on using the Websocket API, please refer to Common > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 1

Websocket URL​

wss://ws.futurescw.info?token={your_token}

Frequency Limit​

None

Subscription Parameters​

ParameterMandatoryTypeDescription
eventTrueStringsubscribe
argsTrueString"spot/match:symbol", where "symbol" is the trading instrument to be subscribed.
Example: "spot/match:BTC-USDT"

Response Parameters​

ParameterTypeDescription
channelStringSubscribed channel, i.e., "spot/match:BTC-USDT"
subjectStringsubject, i.e., "spot/match"
dataArrayData object
priceStringPrice in quote currency
seqStringSequence number
sideStringTrade direction: BUY/SELL
sizeStringQuantity in base currency
symbolStringCurrency pair ID, i.e., 78 : BTC_USDT
Note: The mapping between currency pair ID and Trading instrument can be obtained through Get 24H Trade Summary for All Instruments interface.
timeStringTrade time (timestamp in milliseconds)

Subscription Example​

The following Python code shows how to subscribe to trade data for BTC.

Note: For a complete code example, please refer to Common > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 1.

symbol = "BTC-USDT"
args = f'spot/match:{symbol}'
SpotWebsocketPublic(args) # the function SpotWebsocketPublic() is defined in section (Common > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 1)

Note: For a complete Java code example, please refer to Common > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 1

Response Example​

The following is an example response returned by the above Python subscription. The Websocket will keep updating the trade data in real-time. For brevity, only one trade data is shown below:

{'channel': 'spot/match:BTC-USDT',
'subject': 'spot/match',
'data': '[{
"price":"82861.81",
"seq":"127365683",
"side":"SELL",
"size":"0.0004",
"symbol":"78",
"time":"1741944585776"
}]'
}

Method 2

Authentication​

This is a public Websocket and does not require authentication. For details on using the Websocket API, please refer to Common > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 2

Websocket URL​

wss://ws.futurescw.com

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., "exchange".
Note: Lowercase is recommended.
-typetrueStringDefines the function type, e.g., "fills".
Note: Lowercase is recommended.
-pairCodetrueStringCurrency pair ID, i.e., 78 : BTC_USDT
Note: The mapping between currency pair ID and trading instrument can be obtained through Get 24H Trade Summary for All Instruments interface.

Response Parameters​

ParameterTypeDescription
bizStringChannel name, e.g., "exchange".
pairCodeStringCurrency pair ID, i.e., 78 : BTC_USDT
Note: The mapping between currency pair ID and trading instrument can be obtained through Get 24H Trade Summary for All Instruments interface.
channelStringSubscription type, e.g., "subscribe".
typeStringDefines the function type, e.g., "fills".
-resultBooleanResult of the subscription request: true or false.
dataJsonData object, containing the following fields:
priceStringPrice in quote currency
seqStringSequence number
sideStringTrade direction: BUY/SELL
sizeStringQuantity in base currency
symbolStringCurrency pair ID, i.e., 78 : BTC_USDT
Note: The mapping between currency pair ID and trading instrument can be obtained through Get 24H Trade Summary for All Instruments interface.
timeStringTrade time (timestamp in milliseconds)

Subscription Example​

The following Python code shows how to subscribe to trade data for BTC.

Note: For a complete code example, please refer to Common > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 2.

url = "wss://ws.futurescw.com"
subscription_params = {"event":"sub",
"params":{
"biz":"exchange",
"type":"fills",
"pairCode":"78"}} #78 for BTC-USDT
SpotWebsocketPublic(url, subscription_params) # # the function SpotWebsocketPublic() is defined in section (Common > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 2)

Note: For a complete Java code example, please refer to Common > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 2

Response Example​

The following is an example response returned by the above Python subscription. The Websocket will keep updating the trade data in real-time. For brevity, only one trade data is shown below:

{"biz":"exchange","pairCode":"78","data":{"result":true},"channel":"subscribe","type":"fills"}

{"biz":"exchange","pairCode":"78","data":"[
{\"price\":\"94718.84\",
\"seq\":\"130167227\",
\"side\":\"BUY\",
\"size\":\"0.0010\",
\"symbol\":\"78\",
\"time\":\"1745825592789\"
}]","type":"fills"},.....