Historical Candle Data
Get historical candle data with a 1-minute interval
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/1minute/2023-11-13/2023-11-12' \
--header 'Accept: application/json'
import requests
url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/1minute/2023-11-13/2023-11-12'
headers = {
'Accept': 'application/json'
}
response = requests.get(url, headers=headers)
# Check the response status
if response.status_code == 200:
# Do something with the response data (e.g., print it)
print(response.json())
else:
# Print an error message if the request was not successful
print(f"Error: {response.status_code} - {response.text}")
const axios = require('axios');
const url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/1minute/2023-11-13/2023-11-12';
const headers = {
'Accept': 'application/json'
};
axios.get(url, { headers })
.then(response => {
// Do something with the response data (e.g., print it)
console.log(response.data);
})
.catch(error => {
// Print an error message if the request was not successful
console.error(`Error: ${error.response.status} - ${error.response.data}`);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/1minute/2023-11-13/2023-11-12";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Accept", "application/json")
.build();
try {
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
// Check the response status
if (httpResponse.statusCode() == 200) {
// Do something with the response body (e.g., print it)
System.out.println(httpResponse.body());
} else {
// Print an error message if the request was not successful
System.err.println("Error: " + httpResponse.statusCode() + " - " + httpResponse.body());
}
} catch (Exception e) {
// Handle exceptions
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/1minute/2023-11-12/2023-11-12';
$options = [
'http' => [
'header' => "Accept: application/json\r\n",
'method' => 'GET',
],
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Check for errors
if ($response === FALSE) {
echo 'Error fetching data';
} else {
// Do something with the response (e.g., print it)
echo $response;
}
?>
import upstox_client
from upstox_client.rest import ApiException
api_version = '2.0'
api_instance = upstox_client.HistoryApi()
instrument_key = 'NSE_EQ|INE669E01016'
interval = '1minute'
to_date = '2023-11-13'
from_date = '2023-11-12'
try:
api_response = api_instance.get_historical_candle_data1(instrument_key, interval, to_date,from_date, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
let UpstoxClient = require('upstox-js-sdk');
let apiInstance = new UpstoxClient.HistoryApi();
let apiVersion = "2.0";
let instrumentKey = "NSE_EQ|INE669E01016";
let interval = "1minute";
let toDate = "2023-11-13";
let fromDate = "2023-11-12";
apiInstance.getHistoricalCandleData1(instrumentKey, interval, toDate, fromDate,apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiException;
import com.upstox.api.GetHistoricalCandleResponse;
import io.swagger.client.api.HistoryApi;
public class Main {
public static void main(String[] args) {
HistoryApi apiInstance = new HistoryApi();
String apiVersion = "2.0";
String instrumentKey = "NSE_EQ|INE669E01016";
String interval = "1minute";
String toDate = "2023-11-13";
String fromDate = "2023-11-12";
try {
GetHistoricalCandleResponse result = apiInstance.getHistoricalCandleData1(instrumentKey, interval, toDate, fromDate, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling HistoryApi#getHistoricalCandleData1");
e.printStackTrace();
}
}
}
Get data with a 30-minute interval
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/30minute/2023-11-13/2023-11-12' \
--header 'Accept: application/json'
import requests
url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/30minute/2023-11-13/2023-11-12'
headers = {
'Accept': 'application/json'
}
response = requests.get(url, headers=headers)
# Check the response status
if response.status_code == 200:
# Do something with the response data (e.g., print it)
print(response.json())
else:
# Print an error message if the request was not successful
print(f"Error: {response.status_code} - {response.text}")
const axios = require('axios');
const url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/30minute/2023-11-13/2023-11-12';
const headers = {
'Accept': 'application/json'
};
axios.get(url, { headers })
.then(response => {
// Do something with the response data (e.g., print it)
console.log(response.data);
})
.catch(error => {
// Print an error message if the request was not successful
console.error(`Error: ${error.response.status} - ${error.response.data}`);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/30minute/2023-11-13/2023-11-12";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Accept", "application/json")
.build();
try {
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
// Check the response status
if (httpResponse.statusCode() == 200) {
// Do something with the response body (e.g., print it)
System.out.println(httpResponse.body());
} else {
// Print an error message if the request was not successful
System.err.println("Error: " + httpResponse.statusCode() + " - " + httpResponse.body());
}
} catch (Exception e) {
// Handle exceptions
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/30minute/2023-11-13/2023-11-12';
$options = [
'http' => [
'header' => "Accept: application/json\r\n",
'method' => 'GET',
],
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Check for errors
if ($response === FALSE) {
echo 'Error fetching data';
} else {
// Do something with the response (e.g., print it)
echo $response;
}
?>
import upstox_client
from upstox_client.rest import ApiException
api_version = '2.0'
api_instance = upstox_client.HistoryApi()
instrument_key = 'NSE_EQ|INE669E01016'
interval = '30minute'
to_date = '2023-11-13'
from_date = '2023-11-12'
try:
api_response = api_instance.get_historical_candle_data1(instrument_key, interval, to_date,from_date, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
let UpstoxClient = require('upstox-js-sdk');
let apiInstance = new UpstoxClient.HistoryApi();
let apiVersion = "2.0";
let instrumentKey = "NSE_EQ|INE669E01016";
let interval = "30minute";
let toDate = "2023-11-13";
let fromDate = "2023-11-12";
apiInstance.getHistoricalCandleData1(instrumentKey, interval, toDate, fromDate,apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiException;
import com.upstox.api.GetHistoricalCandleResponse;
import io.swagger.client.api.HistoryApi;
public class Main {
public static void main(String[] args) {
HistoryApi apiInstance = new HistoryApi();
String apiVersion = "2.0";
String instrumentKey = "NSE_EQ|INE669E01016";
String interval = "30minute";
String toDate = "2023-11-13";
String fromDate = "2023-11-12";
try {
GetHistoricalCandleResponse result = apiInstance.getHistoricalCandleData1(instrumentKey, interval, toDate, fromDate, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling HistoryApi#getHistoricalCandleData1");
e.printStackTrace();
}
}
}
Get data with a daily interval
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/day/2023-11-19/2023-11-12' \
--header 'Accept: application/json'
import requests
url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/day/2023-11-19/2023-11-12'
headers = {
'Accept': 'application/json'
}
response = requests.get(url, headers=headers)
# Check the response status
if response.status_code == 200:
# Do something with the response data (e.g., print it)
print(response.json())
else:
# Print an error message if the request was not successful
print(f"Error: {response.status_code} - {response.text}")
const axios = require('axios');
const url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/day/2023-11-19/2023-11-12';
const headers = {
'Accept': 'application/json'
};
axios.get(url, { headers })
.then(response => {
// Do something with the response data (e.g., print it)
console.log(response.data);
})
.catch(error => {
// Print an error message if the request was not successful
console.error(`Error: ${error.response.status} - ${error.response.data}`);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/day/2023-11-19/2023-11-12";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Accept", "application/json")
.build();
try {
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
// Check the response status
if (httpResponse.statusCode() == 200) {
// Do something with the response body (e.g., print it)
System.out.println(httpResponse.body());
} else {
// Print an error message if the request was not successful
System.err.println("Error: " + httpResponse.statusCode() + " - " + httpResponse.body());
}
} catch (Exception e) {
// Handle exceptions
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/day/2023-11-19/2023-11-12';
$options = [
'http' => [
'header' => "Accept: application/json\r\n",
'method' => 'GET',
],
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Check for errors
if ($response === FALSE) {
echo 'Error fetching data';
} else {
// Do something with the response (e.g., print it)
echo $response;
}
?>
import upstox_client
from upstox_client.rest import ApiException
api_version = '2.0'
api_instance = upstox_client.HistoryApi()
instrument_key = 'NSE_EQ|INE669E01016'
interval = 'day'
to_date = '2023-11-13'
from_date = '2023-11-12'
try:
api_response = api_instance.get_historical_candle_data1(instrument_key, interval, to_date,from_date, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
let apiVersion = "2.0";
let instrumentKey = "NSE_EQ|INE669E01016";
let interval = "day";
let toDate = "2023-11-13";
let fromDate = "2023-11-07";
apiInstance.getHistoricalCandleData1(instrumentKey, interval, toDate, fromDate,apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiException;
import com.upstox.api.GetHistoricalCandleResponse;
import io.swagger.client.api.HistoryApi;
public class Main {
public static void main(String[] args) {
HistoryApi apiInstance = new HistoryApi();
String apiVersion = "2.0";
String instrumentKey = "NSE_EQ|INE669E01016";
String interval = "day";
String toDate = "2023-11-13";
String fromDate = "2023-11-12";
try {
GetHistoricalCandleResponse result = apiInstance.getHistoricalCandleData1(instrumentKey, interval, toDate, fromDate, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling HistoryApi#getHistoricalCandleData1");
e.printStackTrace();
}
}
}
Get data with a weekly interval
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/week/2023-11-19/2023-07-12' \
--header 'Accept: application/json'
import requests
url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/week/2023-11-19/2023-07-12'
headers = {
'Accept': 'application/json'
}
response = requests.get(url, headers=headers)
# Check the response status
if response.status_code == 200:
# Do something with the response data (e.g., print it)
print(response.json())
else:
# Print an error message if the request was not successful
print(f"Error: {response.status_code} - {response.text}")
const axios = require('axios');
const url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/week/2023-11-19/2023-07-12';
const headers = {
'Accept': 'application/json'
};
axios.get(url, { headers })
.then(response => {
// Do something with the response data (e.g., print it)
console.log(response.data);
})
.catch(error => {
// Print an error message if the request was not successful
console.error(`Error: ${error.response.status} - ${error.response.data}`);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/week/2023-11-19/2023-07-12";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Accept", "application/json")
.build();
try {
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
// Check the response status
if (httpResponse.statusCode() == 200) {
// Do something with the response body (e.g., print it)
System.out.println(httpResponse.body());
} else {
// Print an error message if the request was not successful
System.err.println("Error: " + httpResponse.statusCode() + " - " + httpResponse.body());
}
} catch (Exception e) {
// Handle exceptions
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/week/2023-11-19/2023-07-12';
$options = [
'http' => [
'header' => "Accept: application/json\r\n",
'method' => 'GET',
],
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Check for errors
if ($response === FALSE) {
echo 'Error fetching data';
} else {
// Do something with the response (e.g., print it)
echo $response;
}
?>
import upstox_client
from upstox_client.rest import ApiException
api_version = '2.0'
api_instance = upstox_client.HistoryApi()
instrument_key = 'NSE_EQ|INE669E01016'
interval = 'week'
to_date = '2023-11-13'
from_date = '2023-10-13'
try:
# Historical candle data
api_response = api_instance.get_historical_candle_data1(instrument_key, interval, to_date,from_date, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
let apiVersion = "2.0";
let instrumentKey = "NSE_EQ|INE669E01016";
let interval = "week";
let toDate = "2023-11-13";
let fromDate = "2023-10-07";
apiInstance.getHistoricalCandleData1(instrumentKey, interval, toDate, fromDate,apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiException;
import com.upstox.api.GetHistoricalCandleResponse;
import io.swagger.client.api.HistoryApi;
public class Main {
public static void main(String[] args) {
HistoryApi apiInstance = new HistoryApi();
String apiVersion = "2.0";
String instrumentKey = "NSE_EQ|INE669E01016";
String interval = "week";
String toDate = "2023-11-13";
String fromDate = "2023-10-13";
try {
GetHistoricalCandleResponse result = apiInstance.getHistoricalCandleData1(instrumentKey, interval, toDate, fromDate, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling HistoryApi#getHistoricalCandleData1");
e.printStackTrace();
}
}
}
Get data with a monthly interval
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/month/2023-11-19/2022-11-12' \
--header 'Accept: application/json'
import requests
url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/month/2023-11-19/2022-11-12'
headers = {
'Accept': 'application/json'
}
response = requests.get(url, headers=headers)
# Check the response status
if response.status_code == 200:
# Do something with the response data (e.g., print it)
print(response.json())
else:
# Print an error message if the request was not successful
print(f"Error: {response.status_code} - {response.text}")
const axios = require('axios');
const url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/month/2023-11-19/2022-11-12';
const headers = {
'Accept': 'application/json'
};
axios.get(url, { headers })
.then(response => {
// Do something with the response data (e.g., print it)
console.log(response.data);
})
.catch(error => {
// Print an error message if the request was not successful
console.error(`Error: ${error.response.status} - ${error.response.data}`);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/month/2023-11-19/2022-11-12";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Accept", "application/json")
.build();
try {
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
// Check the response status
if (httpResponse.statusCode() == 200) {
// Do something with the response body (e.g., print it)
System.out.println(httpResponse.body());
} else {
// Print an error message if the request was not successful
System.err.println("Error: " + httpResponse.statusCode() + " - " + httpResponse.body());
}
} catch (Exception e) {
// Handle exceptions
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/month/2023-11-19/2022-11-12';
$options = [
'http' => [
'header' => "Accept: application/json\r\n",
'method' => 'GET',
],
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Check for errors
if ($response === FALSE) {
echo 'Error fetching data';
} else {
// Do something with the response (e.g., print it)
echo $response;
}
?>
import upstox_client
from upstox_client.rest import ApiException
api_version = '2.0'
api_instance = upstox_client.HistoryApi()
instrument_key = 'NSE_EQ|INE669E01016'
interval = 'month'
to_date = '2023-11-13'
from_date = '2022-10-13'
try:
api_response = api_instance.get_historical_candle_data1(instrument_key, interval, to_date,from_date, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
let apiVersion = "2.0";
let instrumentKey = "NSE_EQ|INE669E01016";
let interval = "month";
let toDate = "2023-11-13";
let fromDate = "2022-10-07";
apiInstance.getHistoricalCandleData1(instrumentKey, interval, toDate, fromDate,apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiException;
import com.upstox.api.GetHistoricalCandleResponse;
import io.swagger.client.api.HistoryApi;
public class Main {
public static void main(String[] args) {
HistoryApi apiInstance = new HistoryApi();
String apiVersion = "2.0";
String instrumentKey = "NSE_EQ|INE669E01016";
String interval = "month";
String toDate = "2023-11-13";
String fromDate = "2022-10-13";
try {
GetHistoricalCandleResponse result = apiInstance.getHistoricalCandleData1(instrumentKey, interval, toDate, fromDate, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling HistoryApi#getHistoricalCandleData1");
e.printStackTrace();
}
}
}
Get historical candle data with a 1-minute interval
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/1minute/2023-11-13' \
--header 'Accept: application/json'
import requests
url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/1minute/2023-11-13'
headers = {
'Accept': 'application/json'
}
response = requests.get(url, headers=headers)
# Check the response status
if response.status_code == 200:
# Do something with the response data (e.g., print it)
print(response.json())
else:
# Print an error message if the request was not successful
print(f"Error: {response.status_code} - {response.text}")
const axios = require('axios');
const url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/1minute/2023-11-13';
const headers = {
'Accept': 'application/json'
};
axios.get(url, { headers })
.then(response => {
// Do something with the response data (e.g., print it)
console.log(response.data);
})
.catch(error => {
// Print an error message if the request was not successful
console.error(`Error: ${error.response.status} - ${error.response.data}`);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/1minute/2023-11-13";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Accept", "application/json")
.build();
try {
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
// Check the response status
if (httpResponse.statusCode() == 200) {
// Do something with the response body (e.g., print it)
System.out.println(httpResponse.body());
} else {
// Print an error message if the request was not successful
System.err.println("Error: " + httpResponse.statusCode() + " - " + httpResponse.body());
}
} catch (Exception e) {
// Handle exceptions
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/1minute/2023-11-12';
$options = [
'http' => [
'header' => "Accept: application/json\r\n",
'method' => 'GET',
],
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Check for errors
if ($response === FALSE) {
echo 'Error fetching data';
} else {
// Do something with the response (e.g., print it)
echo $response;
}
?>
import upstox_client
from upstox_client.rest import ApiException
api_version = '2.0'
api_instance = upstox_client.HistoryApi()
instrument_key = 'NSE_EQ|INE669E01016'
interval = '1minute'
to_date = '2023-11-13'
try:
api_response = api_instance.get_historical_candle_data(instrument_key, interval, to_date, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
let UpstoxClient = require('upstox-js-sdk');
let apiInstance = new UpstoxClient.HistoryApi();
let apiVersion = "2.0";
let instrumentKey = "NSE_EQ|INE669E01016";
let interval = "1minute";
let toDate = "2023-11-13";
apiInstance.getHistoricalCandleData(instrumentKey, interval, toDate, apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiException;
import com.upstox.api.GetHistoricalCandleResponse;
import io.swagger.client.api.HistoryApi;
public class Main {
public static void main(String[] args) {
HistoryApi apiInstance = new HistoryApi();
String apiVersion = "2.0";
String instrumentKey = "NSE_EQ|INE669E01016";
String interval = "1minute";
String toDate = "2023-11-13";
try {
GetHistoricalCandleResponse result = apiInstance.getHistoricalCandleData(instrumentKey, interval, toDate, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling HistoryApi#getHistoricalCandleData1");
e.printStackTrace();
}
}
}
Get data with a 30-minute interval
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/30minute/2023-11-13' \
--header 'Accept: application/json'
import requests
url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/30minute/2023-11-13'
headers = {
'Accept': 'application/json'
}
response = requests.get(url, headers=headers)
# Check the response status
if response.status_code == 200:
# Do something with the response data (e.g., print it)
print(response.json())
else:
# Print an error message if the request was not successful
print(f"Error: {response.status_code} - {response.text}")
const axios = require('axios');
const url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/30minute/2023-11-13';
const headers = {
'Accept': 'application/json'
};
axios.get(url, { headers })
.then(response => {
// Do something with the response data (e.g., print it)
console.log(response.data);
})
.catch(error => {
// Print an error message if the request was not successful
console.error(`Error: ${error.response.status} - ${error.response.data}`);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/30minute/2023-11-13";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Accept", "application/json")
.build();
try {
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
// Check the response status
if (httpResponse.statusCode() == 200) {
// Do something with the response body (e.g., print it)
System.out.println(httpResponse.body());
} else {
// Print an error message if the request was not successful
System.err.println("Error: " + httpResponse.statusCode() + " - " + httpResponse.body());
}
} catch (Exception e) {
// Handle exceptions
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/30minute/2023-11-13';
$options = [
'http' => [
'header' => "Accept: application/json\r\n",
'method' => 'GET',
],
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Check for errors
if ($response === FALSE) {
echo 'Error fetching data';
} else {
// Do something with the response (e.g., print it)
echo $response;
}
?>
import upstox_client
from upstox_client.rest import ApiException
api_version = '2.0'
api_instance = upstox_client.HistoryApi()
instrument_key = 'NSE_EQ|INE669E01016'
interval = '30minute'
to_date = '2023-11-13'
try:
api_response = api_instance.get_historical_candle_data(instrument_key, interval, to_date, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
let UpstoxClient = require('upstox-js-sdk');
let apiInstance = new UpstoxClient.HistoryApi();
let apiVersion = "2.0";
let instrumentKey = "NSE_EQ|INE669E01016";
let interval = "30minute";
let toDate = "2023-11-13";
apiInstance.getHistoricalCandleData(instrumentKey, interval, toDate, apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiException;
import com.upstox.api.GetHistoricalCandleResponse;
import io.swagger.client.api.HistoryApi;
public class Main {
public static void main(String[] args) {
HistoryApi apiInstance = new HistoryApi();
String apiVersion = "2.0";
String instrumentKey = "NSE_EQ|INE669E01016";
String interval = "30minute";
String toDate = "2023-11-13";
try {
GetHistoricalCandleResponse result = apiInstance.getHistoricalCandleData(instrumentKey, interval, toDate, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling HistoryApi#getHistoricalCandleData1");
e.printStackTrace();
}
}
}
Get data with a daily interval
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/day/2023-11-19' \
--header 'Accept: application/json'
import requests
url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/day/2023-11-19'
headers = {
'Accept': 'application/json'
}
response = requests.get(url, headers=headers)
# Check the response status
if response.status_code == 200:
# Do something with the response data (e.g., print it)
print(response.json())
else:
# Print an error message if the request was not successful
print(f"Error: {response.status_code} - {response.text}")
const axios = require('axios');
const url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/day/2023-11-19';
const headers = {
'Accept': 'application/json'
};
axios.get(url, { headers })
.then(response => {
// Do something with the response data (e.g., print it)
console.log(response.data);
})
.catch(error => {
// Print an error message if the request was not successful
console.error(`Error: ${error.response.status} - ${error.response.data}`);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/day/2023-11-19";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Accept", "application/json")
.build();
try {
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
// Check the response status
if (httpResponse.statusCode() == 200) {
// Do something with the response body (e.g., print it)
System.out.println(httpResponse.body());
} else {
// Print an error message if the request was not successful
System.err.println("Error: " + httpResponse.statusCode() + " - " + httpResponse.body());
}
} catch (Exception e) {
// Handle exceptions
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/day/2023-11-19';
$options = [
'http' => [
'header' => "Accept: application/json\r\n",
'method' => 'GET',
],
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Check for errors
if ($response === FALSE) {
echo 'Error fetching data';
} else {
// Do something with the response (e.g., print it)
echo $response;
}
?>
import upstox_client
from upstox_client.rest import ApiException
api_version = '2.0'
api_instance = upstox_client.HistoryApi()
instrument_key = 'NSE_EQ|INE669E01016'
interval = 'day'
to_date = '2023-11-13'
try:
api_response = api_instance.get_historical_candle_data(instrument_key, interval, to_date, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
let apiVersion = "2.0";
let instrumentKey = "NSE_EQ|INE669E01016";
let interval = "day";
let toDate = "2023-11-13";
apiInstance.getHistoricalCandleData(instrumentKey, interval, toDate, apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiException;
import com.upstox.api.GetHistoricalCandleResponse;
import io.swagger.client.api.HistoryApi;
public class Main {
public static void main(String[] args) {
HistoryApi apiInstance = new HistoryApi();
String apiVersion = "2.0";
String instrumentKey = "NSE_EQ|INE669E01016";
String interval = "day";
String toDate = "2023-11-13";
try {
GetHistoricalCandleResponse result = apiInstance.getHistoricalCandleData(instrumentKey, interval, toDate, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling HistoryApi#getHistoricalCandleData1");
e.printStackTrace();
}
}
}
Get data with a weekly interval
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/week/2023-11-19' \
--header 'Accept: application/json'
import requests
url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/week/2023-11-19'
headers = {
'Accept': 'application/json'
}
response = requests.get(url, headers=headers)
# Check the response status
if response.status_code == 200:
# Do something with the response data (e.g., print it)
print(response.json())
else:
# Print an error message if the request was not successful
print(f"Error: {response.status_code} - {response.text}")
const axios = require('axios');
const url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/week/2023-11-19';
const headers = {
'Accept': 'application/json'
};
axios.get(url, { headers })
.then(response => {
// Do something with the response data (e.g., print it)
console.log(response.data);
})
.catch(error => {
// Print an error message if the request was not successful
console.error(`Error: ${error.response.status} - ${error.response.data}`);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/week/2023-11-19";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Accept", "application/json")
.build();
try {
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
// Check the response status
if (httpResponse.statusCode() == 200) {
// Do something with the response body (e.g., print it)
System.out.println(httpResponse.body());
} else {
// Print an error message if the request was not successful
System.err.println("Error: " + httpResponse.statusCode() + " - " + httpResponse.body());
}
} catch (Exception e) {
// Handle exceptions
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/week/2023-11-19';
$options = [
'http' => [
'header' => "Accept: application/json\r\n",
'method' => 'GET',
],
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Check for errors
if ($response === FALSE) {
echo 'Error fetching data';
} else {
// Do something with the response (e.g., print it)
echo $response;
}
?>
import upstox_client
from upstox_client.rest import ApiException
api_version = '2.0'
api_instance = upstox_client.HistoryApi()
instrument_key = 'NSE_EQ|INE669E01016'
interval = 'week'
to_date = '2023-11-13'
try:
api_response = api_instance.get_historical_candle_data(instrument_key, interval, to_date, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
let apiVersion = "2.0";
let instrumentKey = "NSE_EQ|INE669E01016";
let interval = "week";
let toDate = "2023-11-13";
apiInstance.getHistoricalCandleData(instrumentKey, interval, toDate, apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiException;
import com.upstox.api.GetHistoricalCandleResponse;
import io.swagger.client.api.HistoryApi;
public class Main {
public static void main(String[] args) {
HistoryApi apiInstance = new HistoryApi();
String apiVersion = "2.0";
String instrumentKey = "NSE_EQ|INE669E01016";
String interval = "week";
String toDate = "2023-11-13";
try {
GetHistoricalCandleResponse result = apiInstance.getHistoricalCandleData(instrumentKey, interval, toDate, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling HistoryApi#getHistoricalCandleData1");
e.printStackTrace();
}
}
}
Get data with a monthly interval
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/month/2023-11-19' \
--header 'Accept: application/json'
import requests
url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/month/2023-11-19'
headers = {
'Accept': 'application/json'
}
response = requests.get(url, headers=headers)
# Check the response status
if response.status_code == 200:
# Do something with the response data (e.g., print it)
print(response.json())
else:
# Print an error message if the request was not successful
print(f"Error: {response.status_code} - {response.text}")
const axios = require('axios');
const url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/month/2023-11-19';
const headers = {
'Accept': 'application/json'
};
axios.get(url, { headers })
.then(response => {
// Do something with the response data (e.g., print it)
console.log(response.data);
})
.catch(error => {
// Print an error message if the request was not successful
console.error(`Error: ${error.response.status} - ${error.response.data}`);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/month/2023-11-19";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest httpRequest = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Accept", "application/json")
.build();
try {
HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
// Check the response status
if (httpResponse.statusCode() == 200) {
// Do something with the response body (e.g., print it)
System.out.println(httpResponse.body());
} else {
// Print an error message if the request was not successful
System.err.println("Error: " + httpResponse.statusCode() + " - " + httpResponse.body());
}
} catch (Exception e) {
// Handle exceptions
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/month/2023-11-19';
$options = [
'http' => [
'header' => "Accept: application/json\r\n",
'method' => 'GET',
],
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Check for errors
if ($response === FALSE) {
echo 'Error fetching data';
} else {
// Do something with the response (e.g., print it)
echo $response;
}
?>
import upstox_client
from upstox_client.rest import ApiException
api_version = '2.0'
api_instance = upstox_client.HistoryApi()
instrument_key = 'NSE_EQ|INE669E01016'
interval = 'month'
to_date = '2023-11-13'
try:
api_response = api_instance.get_historical_candle_data(instrument_key, interval, to_date, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling HistoryApi->get_historical_candle_data: %s\n" % e)
let apiVersion = "2.0";
let instrumentKey = "NSE_EQ|INE669E01016";
let interval = "month";
let toDate = "2023-11-13";
apiInstance.getHistoricalCandleData(instrumentKey, interval, toDate, apiVersion, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiException;
import com.upstox.api.GetHistoricalCandleResponse;
import io.swagger.client.api.HistoryApi;
public class Main {
public static void main(String[] args) {
HistoryApi apiInstance = new HistoryApi();
String apiVersion = "2.0";
String instrumentKey = "NSE_EQ|INE669E01016";
String interval = "month";
String toDate = "2023-11-13";
try {
GetHistoricalCandleResponse result = apiInstance.getHistoricalCandleData(instrumentKey, interval, toDate, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling HistoryApi#getHistoricalCandleData1");
e.printStackTrace();
}
}
}