Nifty Index History data not returning

I am trying to get 5 mins candle historical data for Nifty index, but it throws {‘s’: ‘error’, ‘code’: -300, ‘message’: ‘Please provide a valid symbol’} exception.

My input to history API on V2 is as follows:-

{‘symbol’: ‘NSE:NIFTY50-INDEX’, ‘resolution’: ‘5’, ‘date_format’: 1, ‘range_from’: ‘2024-02-01’, ‘range_to’: ‘2024-02-01’, ‘cont_flag’: 1}

Please let me know what’s wrong with this input?

Hi @abhinandan.patil.ih0a9bqj
Please upgrade to V3 to avoid such errors.

Please follow our API latest API docs for this
Docs link : [https://myapi.fyers.in/docsv3

and](https://myapi.fyers.in/docsv3and) follow code from this github repo
Github Repo : https://github.com/FyersDev/fyers-api-sample-code/tree/sample_v3/v3

Hello Abhishek,

I am still getting this error:

1709317450490 :: history :: {‘symbol’: ‘NSE:NIFTYBANK-INDEX’, ‘resolution’: ‘D’, ‘date_format’: ‘1’, ‘range_from’: datetime.date(2023, 8, 14), ‘range_to’: datetime.date(2024, 3, 1), ‘cont_flag’: ‘1’} :: 1709317450912 :: {‘s’: ‘error’, ‘code’: -300, ‘message’: ‘Please provide a valid symbol’}

When I am trying to use V3, as per Git,

from fyers_apiv3 import fyersModel
session = fyersModel.SessionModel(
   client_id=client_id[i],
   secret_key=secret_key[i], 
   redirect_uri=url[i], 
   response_type='code', 
   grant_type='authorization_code')

I get below error:

session = fyersModel.SessionModel(

          ^^^^^^^^^^^^^^^^^^^^^^^

AttributeError: module ‘fyers_api.fyersModel’ has no attribute ‘SessionModel’

Could you please tell me whats the reason for this error?
Basically I want to get historic data for BankNifty Index. for which originally I am getting error for Symbol not found

I am still getting the same error