Subscribe 24H Trades Summary for All Instruments
API Description
This Websocket API provides real-time spot market instrument, streaming live bid and ask data.
Note: 24H Trade Summary data is accessible via both RESTful and Websocket APIs. This page describes the Websock API. For information on the RESTful API, please click here
Precautions
- This websocket returns the real time data for all trading instruments listed on exchange.
- Only method 2 is available to achieve this functionality.
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 > Spot > Websocket Public Interface > Method 2
Websocket URL
Frequency Limit
None
Subscription Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| event | true | String | Subscribe or unsubscribe: sub: subscribe, unsub: unsubscribe. Note: This parameter is case-sensitive. |
| params | true | Json | Requested parameter objects including: |
| -biz | true | String | Specifies the channel, e.g., "exchange". Note: Lowercase is recommended. |
| -type | true | String | Defines the function type, e.g., "ticker_all". Note: Lowercase is recommended. |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| biz | String | Channel name, e.g., "exchange". |
| channel | String | Subscription type, e.g., "subscribe". |
| type | String | Defines the function type, e.g., "ticker_all". |
| -result | Boolean | Result of the subscription request: true/false. |
| data | Json | Data object, containing the following fields: |
| -activityState | Integer | State of the activity (specific meaning not provided). |
| -currencyVol | BigDecimal | Total volume of currency traded. |
| -fPartitionIds | String | IDs related to market or platform partitioning. |
| -fav | Boolean | Whether the coin pair is marked as a favorite. |
| -hotCoinSort | Integer | Ranking of the coin based on popularity or trading volume. |
| -leftCoinName | String | Name of the base currency of the instrumnet, i.e., BTC |
| -leftCoinUrl | String | URL to the image of the left coin. |
| -newCoinSort | Integer | Sorting rank of the coin in new listings ( users can ignore it) |
| -oneDayHighest | BigDecimal | Highest price of the coin in the last 24 hours.( in quote currency) |
| -oneDayLowest | BigDecimal | Lowest price of the coin in the last 24 hours.(in quote currency) |
| -oneDayTotal | BigDecimal | Total amount of the coin traded in the last 24 hours. ( in base currency) |
| -price | BigDecimal | Latest price in quote currency. |
| -rightCoinName | String | Name of the quote currency of the instrumnet, i.e., USDT |
| -rose | BigDecimal | Percentage change in price in terms of quote currency. |
| -selective | Boolean | Indicates if the data is selective for specific conditions. ( users can ignore it) |
| -symbol | String | Currency symbol used for pricing (e.g., "$"). |
| -tmId | Integer | Currency 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. |
| -transferPrice | BigDecimal | Transfer price ( users can ignore it) |
| -transferSymbol | String | Symbol for the converted currency ( users can ignore it) |
Subscription Example
The following Python code shows how to subscribe for BTC-USDT.
Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 2.
url = "wss://ws.futurescw.com"
subscription_params = {"event":"sub",
"params":{
"biz":"exchange",
"type":"ticker_all"}}
SpotWebsocketPublic(url, subscription_params) # the function SpotWebsocketPublic() is defined in section (Introduction > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 2)
Note: For a complete Java code example, please refer to Introduction > 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 in real-time. For brevity, only the initial response is provided below:
{"biz":"exchange","data":{"result":true},"channel":"subscribe","type":"ticker_all"}
{"biz":"exchange","data":"[{\"activityState\":0,\"currencyVol\":604768021.9400,\"fPartitionIds\":\"1,2006\",\"fav\":false,\"hotCoinSort\":46,\"leftCoinName\":\"BTC\",\"leftCoinUrl\":\"https://hkto-prod.oss-accelerate.aliyuncs.com/201810020046047_T9g8i.png\",\"newCoinSort\":0,\"oneDayHighest\":\"94827.32\",\"oneDayLowest\":\"92788.41\",\"oneDayTotal\":\"6434.1919000000\",\"price\":\"94728.91\",\"rightCoinName\":\"USDT\",\"rose\":\"0.0063\",\"selective\":false,\"symbol\":\"$\",\"tmId\":78,\"transferPrice\":\"664049.6591\",\"transferSymbol\":\"¥\"},.........]","type":"ticker_all"},........