Symbols for Nifty and Banknifty index in Fyers API V2 are not working

I'm trying to fetch the history of Nifty and Banknifty using Fyers API V2. But I'm running into the following error:

{'s': 'error', 'code': -300, 'message': 'Please provide a valid symbol'}

This is my code:

today = date.today()
yesterday = today - timedelta(5)

data = {
    "symbol":"NSE:NIFTY50-INDEX",
    "resolution":"5",
    "date_format":"1",
    "range_from":yesterday,
    "range_to":today,
    "cont_flag":"1"
}

response = fyers.history(data=data)

response

I know I'm using the correct symbols unless they are changed by Fyers. So can anyone explain the problem?

1 reply