Request Error of 400

when i run this code at that time it is correct -

const axios = require('axios');

const url = 'https://api.upstox.com/v2/historical-candle/intraday/NSE_EQ%7CINE848E01016/1minute';
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}`);
    });

tell me how should i get NSE_index | nifty50 .
i need complte url please let me know ASAP

Please check the sample code for the reference

but this is for intraday i want the old data of candle .i checked this and i have been using this code of intraday.

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.

1 Like

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 .