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.