Skip to main content

Subscribe Incremental Order Book

API Description

This Websocket API provides real-time incremental order book for spot market instrument, streaming live bids and asks data.

Note: Incremental Order Book data is only available via Websocket API.

Precautions

  1. This interface provides an incremental order book with sequence numbers. If there are no changes in the market in certain sequence, the response will include empty asks or bids accordingly.
  2. 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

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., "depth".
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 Instrumentsinterface.

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., "depth".
-resultBooleanResult of the subscription request:
true/false.
dataJsonData object, containing the following fields:
-startSeqLongStarting sequence number of depth update.
-endSeqLongEnding sequence number of depth update.
-asksArraySell-side depth
-StringPrice in quote currency
-StringQuantity in base currency
-StringSequence number
-bidsArrayBuy-side depth
-StringPrice in quote currency
-StringQuantity in base currency
-StringSequence number

Subscription Example

The following Python code shows how to subscribe incremental order book 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":"depth",
"pairCode":"78"}} # "78" : BTC-USDT
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 incremental order book in real-time. For brevity, only the initial response is provided below:

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

{"biz":"exchange","pairCode":"78","data":
"{\"startSeq\":4999544967,\"endSeq\":4999544973,
\"asks\":[
[\"94734.66\",\"0.1137\",\"4999544972\"],
[\"94733.65\",\"0.0685\",\"4999544971\"],
[\"94732.06\",\"0.0000\",\"4999544970\"]],
\"bids\":[
[\"94730.63\",\"0.0903\",\"4999544967\"],
[\"94728.84\",\"0.0554\",\"4999544973\"]]}","type":"depth"},......