Candles
Get historical OHLCV (open / high / low / close / volume) candlestick data for a symbol.
HTTP
| Method | GET |
| Endpoint | /trade/api/v2/candles |
Request Parameters
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
exchange | string | Yes | See Exchange Identifiers. |
symbol | string | Yes | BASE/QUOTE, e.g. BTC/INR, BTC/USDT. |
interval | integer | Yes | Candle duration in minutes. e.g. 1, 5, 60, 1440. |
start_time | integer | Yes | Range start (Unix milliseconds). |
end_time | integer | Yes | Range end (Unix milliseconds). |
Example
- Python
- Java
- Go
- Node.js
import requests
headers, path = sign_request("GET", "/trade/api/v2/candles", params={
"exchange": "coinswitchx",
"symbol": "BTC/INR",
"interval": "60",
"start_time": "1647388800000",
"end_time": "1662681600000",
})
response = requests.get(BASE_URL + path, headers=headers)
print(response.json())
HashMap<String, String> p = new HashMap<>();
p.put("exchange", "coinswitchx");
p.put("symbol", "BTC/INR");
p.put("interval", "60");
p.put("start_time", "1647388800000");
p.put("end_time", "1662681600000");
HttpResponse<String> resp = client.send(
"GET", "/trade/api/v2/candles", p, null);
System.out.println(resp.body());
headers, p, err := SignRequest("GET", "/trade/api/v2/candles", map[string]string{
"exchange": "coinswitchx",
"symbol": "BTC/INR",
"interval": "60",
"start_time": "1647388800000",
"end_time": "1662681600000",
})
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/candles', {
"exchange": "coinswitchx",
"symbol": "BTC/INR",
"interval": "60",
"start_time": "1647388800000",
"end_time": "1662681600000",
});
const r = await fetch(BASE_URL + path, {
method: 'GET',
headers,
});
console.log(await r.json());
Response
{
"data": [
{
"o": "1591001.000000000000",
"h": "1610988.000000000000",
"l": "1588000.000000000000",
"c": "1591000.000000000000",
"interval": "60",
"symbol": "BTC/INR",
"close_time": "1662681600000",
"volume": "0.304680000000",
"start_time": "1662678000000"
}
]
}
Response Parameters
data is an array of candles. Each entry:
| Field | Type | Description |
|---|---|---|
o | string | Open price. |
h | string | High price. |
l | string | Low price. |
c | string | Close price. |
volume | string | Trade volume in base asset over the candle period. |
symbol | string | Symbol, e.g. "BTC/INR". |
interval | string | Echo of the requested interval, in minutes. |
start_time | string | Candle start (Unix milliseconds). |
close_time | string | Candle close (Unix milliseconds). |
For real-time 1-minute candles, use the Candlestick WebSocket.