Skip to main content

Get Order Book of an Instrument

API Description​

This interface allows querying the depth data, including bids and asks, for a specified instrument.

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

Precautions​

  1. This interface does not allow users to specify bid/ask levels. By default, it returns 20 levels of bids and asks in response.
  2. The interface does not provide timestamp information.

Authentication​

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

Request Method​

GET

Endpoint​

/v1/perpumPublic/depth

Frequency Limit​

The frequency limit for this interface is 10 requests/2s per user ID and IP. In addition to this per-interface limit, a global rate limit is also enforced.

For detailed information on Global rate limits and API Rate Limiting Policy, please refer to the "Frequency Limit" section at click here

Request Parameters​

ParameterMandatoryTypeDescription
basetrueStringNote: for USDT contracts, pass only the base currency name, for example BTCUSDT can use BTC; for USDC contracts, pass the full trading pair, for example BTC_USDC. 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
asksListSell-side depth containing 20 levels of ask
bidsListBuy-side depth containing 20 levels of bid
mBigDecimalQuantity of the base currency
pBigDecimalPrice of the base currency
nStringBase currency of the instrument, e.g., BTC.
tsLongTimestamp (ms)

Request Example​

The following Python code shows how to get the order book of BTC.

Note: For a complete code example, please refer to Common > Authentication & Code Snippet > Futures > RESTful Public Interface.

api_url = "/v1/perpumPublic/depth"
params = {"base" : "BTC"}
FuturesRestfulPublic(api_url, params) # function FuturesRestfulPublic() is defined in section (Common > Authentication & Code Snippet > Futures > RESTful Public Interface)

Note: For a complete Java code example, please refer to Common > Authentication & Code Snippet > Futures > RESTful Public Interface.

Response Example​

The following is an example response returned by the above Python request. The actual response for the above request returns 20 levels of bids and asks. For brevity, only 5 levels are shown below:

{'code': 0,
'data': {'asks': [{'m': 0.516, 'p': 89942.2},
{'m': 0.807, 'p': 89942.3},
{'m': 0.15, 'p': 89942.4},
{'m': 0.542, 'p': 89942.5},
...............................,
{'m': 0.475, 'p': 89944.7}],
'bids': [{'m': 0.044, 'p': 89942.1},
{'m': 0.3, 'p': 89941.8},
{'m': 0.517, 'p': 89941.5},
{'m': 0.553, 'p': 89941.3},
...............................,
{'m': 0.046, 'p': 89938.7}],
'n': 'btc',
't': None,
'ts': 1775443378356},
'msg': ''}