Skip to main content

Subscribe 24H Trade Summary

API Description​

This Websocket provides real-time 24 hour trading summary for the specified trading instrument. It includes key market metric such as the latest transaction price, highest bid, lowest ask, 24-hour trading volume, etc..

Note: 24H Trade Summary is only available via Websocket API.

Precautions​

  1. Currently, two methods are availabe for 24H trade summary 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/market-api-ticker:symbol", where symbol is the trading instrument to be subscribed
Example: "spot/market-api-ticker:BTC-USDT"

Response Parameters​

ParameterTypeDescription
channelStringSubscribed channel, i.e., 'spot/market-api-ticker:BTC-USDT'
subjectstringsubject: 'spot/market-api-ticker'
buystringBid
changePricestringPrice change
changeRateStringPrice change percentage
highStringHighest price in the past 24 hours
lastStringLatest price
lowStringLowest price in the past 24 hours
openStringOpening Price
sellStringAsk
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
volstringTrading volume in base currency
volValueStringAmount in USDT

Subscription Example​

The following Python code shows how to subscribe to 24 Hour Trading Summary for BTC.

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

symbol = "BTC-USDT"
args = f'spot/market-api-ticker:{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 subscription will keep updating the 24-hour trade summary in real-time. For brevity, only the initial response is provided below:

{'channel': 'spot/market-api-ticker:BTC-USDT',
'subject': 'spot/market-api-ticker',
'data': '{
"buy":"82821.35",
"changePrice":"-610.48",
"changeRate":"-0.007317",
"high":"83799.09",
"last":"82821.45",
"low":"79998.45",
"open":"83431.93",
"sell":"82821.40",
"symbol":"78",
"vol":"10329.2388",
"volValue":"843619014.31"
}'
},.....

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., "ticker".
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".
typeStringMessage type, e.g., "ticker".
-resultBooleanResult of the subscription request: true or false.
dataJsonData object, containing the following fields:
changePricebigdecimalPrice change
changeRatebigdecimalPrice change rates
highbigdecimalHighest price in the past 24 hours ( in quote currency)
lastbigdecimalLatest price in the past 24 hours ( in quote currency)
lowbigdecimalLowest price in the past 24 hours ( in quote currency)
openbigdecimalOpening Price ( in quote 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
volbigdecimalTrading volume in base currency
volValuebigdecimalAmount in USDT

Subscription Example​

The following Python code shows how to subscribe to 24H trading summary for BTC-USDT.

Note: For complete code, 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":"ticker",
"pairCode":"78"}} # "78" : 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 subscription will keep updating the 24H trade summary in real-time. For brevity, only the initial response is provided below:

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

{"biz":"exchange","pairCode":"78","data":
"{\"changePrice\":\"535.14\",
\"changeRate\":\"0.005678\",
\"high\":\"94827.32\",
\"last\":\"94788.99\",
\"low\":\"92788.41\",
\"open\":\"94253.85\",
\"symbol\":\"78\",
\"vol\":\"6209.9048\",
\"volValue\":\"583370376.71\"
}","type":"ticker"},.....