Get Order Book
API Description
This interface allows querying the spot market order book data for specified trading instruments. Users may request either 5-level or 20-level depth for bids and asks.
Note: Order book data is accessible via both RESTful and Websocket APIs. This page describes the RESTful API. For information on the Websocket API, please click here
Precautions
- This interface does not provide timestamp information.
- Users can query order book data for single or multiple instruments in one request.
Authentication
This is a public interface and does not require authentication. For details on using the RESTful API, please refer to Introduction > Authentication & Code Snippet > Spot > RESTful Public Interface.
Request Method
GET
Endpoint
/api/v1/public?command=returnOrderBook
Frequency Limit
The frequency limit for this interface is 10 requests/second per 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
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| size | Integer | False | Order book depth data levels (5, 20) Note: Default is 5 |
| symbol | String | True | Trading instrument(s). Multiple tranding instruments allowed, separated by commas. Example: "BTC_USDT,ETH_USDT" Note: Max 20 instrument per request |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| asks | Array | Sell-side depth Note: 5 levels of asks are returned by default. |
| -quantity | String | Trading volume in base currency |
| -price | String | Price in base currency |
| bids | Array | Buy-side depth Note: 5 levels of bids are returned by default. |
| -quantity | String | Trading volume in base currency |
| -price | String | Price in base currency |
| pair | String | Trading instrument |
Request Example
The following Python code shows how to get order book data for BTC_USDT and ETH_USDT.
Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Spot > RESTful Public Interface.
api_url= "/api/v1/public?command=returnOrderBook"
params= {"size" : 5,
"symbol" : "BTC_USDT,ETH_USDT",}
SpotRestfulPublic(api_url, params) # function SpotRestfulPublic() is defined in section (Introduction > Authentication & Code Snippet > Spot > RESTful Public Interface)
Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Spot > RESTful Public Interface.
Response Example
The following is an example response returned by the above Python request.
{
'code': '200',
'data': [
{
'asks': [
['87668.0600', '0.5452'],
['87668.1800', '0.7087'],
['87668.2900', '0.0165'],
['87668.4100', '0.0305'],
['87668.5200', '1.2592']
],
'bids': [
['87667.4400', '0.3312'],
['87666.8500', '0.0459'],
['87666.2700', '0.0492'],
['87665.6800', '0.0734'],
['87665.1000', '0.0616']
],
'pair': 'BTC_USDT'
},
{
'asks': [
['2926.3200', '21.7389'],
['2926.4800', '25.2155'],
['2926.5700', '25.6872'],
['2926.6700', '23.6043'],
['2926.7900', '12.4068']
],
'bids': [
['2926.1300', '12.8027'],
['2926.0300', '18.8028'],
['2925.9400', '21.5573'],
['2925.7800', '23.1259'],
['2925.6900', '23.7506']
],
'pair': 'ETH_USDT'
}
],
'msg': 'SUCCESS',
'success': True,
'failed': False
}