Historical candle data
GET /history/candleData
Gets the historical candle data such as Open, high, low, close, last traded price and volume within specific dates for a specific symbol. From date is mandatory. End date is optional and defaults to yesterday.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
exchange | string | false | Name of the exchange. Valid values are (BSE/ NSE/ NFO/ MCX/ CDS). Default is NSE if not provided. |
symbolName | string | true | Symbol name of the scrip. |
fromDate | string | true | Start date in yyyy-MM-dd format. |
toDate | string | false | End date in yyyy-MM-dd format. If not provided, data is fetched only for the fromDate. |
Sample Code
bash
curl -X GET 'https://tradeapi.samco.in/history/candleData?symbolName=INFY&fromDate=2019-10-11' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'x-session-token: <SESSION_TOKEN>'java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Sample {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://tradeapi.samco.in/history/candleData?symbolName=INFY&fromDate=2019-10-11"))
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("x-session-token", "<SESSION_TOKEN>")
.GET()
.build();
HttpResponse<String> response =
client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}js
(async () => {
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'x-session-token': '<SESSION_TOKEN>',
};
const response = await fetch('https://tradeapi.samco.in/history/candleData?symbolName=INFY&fromDate=2019-10-11', {
method: 'GET',
headers,
});
const data = await response.json();
console.log(data);
})();py
import requests
import json
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'x-session-token': '<SESSION_TOKEN>',
}
r = requests.get('https://tradeapi.samco.in/history/candleData?symbolName=INFY&fromDate=2019-10-11',
headers=headers)
print(r.json())Sample Responses
json
{
"serverTime": "12/12/19 16:20:11",
"msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
"status": "Success",
"statusMessage": "Request successful",
"historicalCandleData": [
{
"date": "2019-11-01",
"open": "689.9",
"high": "694.0",
"low": "682.75",
"close": "688.0",
"ltp": "688.0",
"volume": "600344"
}
]
}Response Schema
Status Code 200
| Name | Type | Description |
|---|---|---|
serverTime | string | Time at Server. |
msgId | string | Unique identifier for the request. Quote this to the support team if needed. |
status | string | Response status. Can be Success or Failure. |
statusMessage | string | Status message of the response. |
historicalCandleData | [object] | List of historical candle data. |
date | string | Date for which CandleData is shown. |
open | string | Opening price of the market snapshot. |
high | string | Highest value of the market snapshot. |
low | string | Lowest value of the market snapshot. |
close | string | Closing price of the market snapshot. |
ltp | string | Last traded price. |
volume | string | Amount of security traded on the specific day. |