Intraday candle api provides OHLC (Open, High, Low, Close) values for instruments during the current trading day. If you want to old data of candle then use Historical candle api.
Below is a working Node.js code snippet that retrieves candle data for the Nifty 50 index on 2024-03-21:
const axios = require('axios');
const url = 'https://api.upstox.com/v2/historical-candle/NSE_INDEX%7CNifty%2050/1minute/2024-03-21/2024-03-21';
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.data);
})
.catch(error => {
// Print an error message if the request was not successful
console.error(`Error: ${error.response.status} - ${error.response.data}`);
});
Please do check our Example Codes
I hope the above information is helpful.
After carefully watch the code i recognized that my instrument key was wrong i was writing it as not mentioned.
yes this was very helpful and thank you very much .