Depth
Get a snapshot of the order book (bids and asks) for a symbol on a given exchange.
HTTP
| Method | GET |
| Endpoint | /trade/api/v2/depth |
Request Parameters
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
exchange | string | Yes | See Exchange Identifiers. |
symbol | string | Yes | BASE/QUOTE, e.g. BTC/INR, BTC/USDT. |
Example
- Python
- Java
- Go
- Node.js
import requests
headers, path = sign_request("GET", "/trade/api/v2/depth",
params={"exchange": "coinswitchx", "symbol": "btc/inr"})
response = requests.get(BASE_URL + path, headers=headers)
print(response.json())
HttpResponse<String> resp = client.send(
"GET", "/trade/api/v2/depth",
Map.of("exchange", "coinswitchx", "symbol", "btc/inr"), null);
System.out.println(resp.body());
headers, p, err := SignRequest("GET", "/trade/api/v2/depth", map[string]string{"exchange": "coinswitchx", "symbol": "btc/inr"})
if err != nil { panic(err) }
req, _ := http.NewRequest("GET", BaseURL+p, nil)
for k, v := range headers { req.Header.Set(k, v) }
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
out, _ := io.ReadAll(resp.Body)
fmt.Println(string(out))
const {signRequest, BASE_URL} = require('./reference-client');
const {headers, path} = signRequest('GET', '/trade/api/v2/depth', {"exchange": "coinswitchx", "symbol": "btc/inr"});
const r = await fetch(BASE_URL + path, {
method: 'GET',
headers,
});
console.log(await r.json());
Response
{
"data": {
"symbol": "DOGE/INR",
"timestamp": 1686514361972,
"bids": [
["5.82", "4350"]
],
"asks": [
["5.8664", "1238"]
]
}
}
Response Parameters
| Field | Type | Description |
|---|---|---|
symbol | string | Symbol echoed back, e.g. "DOGE/INR". |
timestamp | integer | Snapshot time (Unix milliseconds). |
bids | array | Sorted descending. Each entry is [price (string), quantity (string)]. |
asks | array | Sorted ascending. Each entry is [price (string), quantity (string)]. |
For real-time depth updates, use the Order Book WebSocket.