Instrument Key for Nifty 50 gives "Invalid Instrument key" error

I am using c# to fetch Intraday Candle Data which works fine if I pass stock (NSE_EQ|INE101A01026) or options (NSE_FO|51801) but does not work for index (NSE_INDEX|Nifty 50) It gives “Invalid Instrument key” error.

What do i need to alter in the code or instrument_key in order to get index data from this api.

the request absolute URL that gets form is,

“https://api.upstox.com/v2/historical-candle/intraday/NSE_INDEX%7CNIFTY%2050/1minute”

and the code is,

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, “https://api.upstox.com/v2/historical-candle/intraday/” + requestobj.Symbol.Trim() + “/1minute”);
request.Headers.Add(“Accept”, “application/json”);
request.Headers.Add(“Authorization”, "Bearer " + requestobj.AccessCode);

    var response = client.SendAsync(request);
    
    var jsonResponse = response.Result.Content.ReadAsStringAsync();

Please help

The correct instrument key for Nifty 50 is NSE_INDEX|Nifty 50. However, in your cURL request, the instrument key is NSE_INDEX|NIFTY 50. Using “NIFTY” in uppercase will result in an invalid instrument key error.

Please use this URL as a reference: https://api.upstox.com/v2/historical-candle/intraday/NSE_INDEX%7CNifty%2050/1minute

Additionally, refer to the Instrument | JSON Files for correct and updated instrument keys.

Thank you.

1 Like

Thanks a lot Ketan for quick and precise reply. It worked.

This symbol is not working for v3 api

params:
{‘instrument_key’: ‘NSE_INDEX|Nifty 50’, ‘interval’: ‘5m’, ‘start_time’: ‘2025-05-19T18:47:08.389638’, ‘end_time’: ‘2025-05-20T18:47:08.389638’}
url: “https://api.upstox.com/v3/historical-candle

what should be the symbol for nifty 50 in v3 api

@Anand_48354851 It looks like some of the parameters being sent might be incorrect.

Please review the required parameters in the API documentation and refer to the example code for proper usage.

1 Like

Thanks, working now.

NIFTY_SYMBOL = “NSE_INDEX|Nifty 50”
url = f"https://api.upstox.com/v3/historical-candle/intraday/{NIFTY_SYMBOL}/minutes/{INTERVAL}"
resp = requests.get(url, headers=headers)

1 Like