Index_history is not working

@dexter on slack you are unavailable on forum you are unavailable, should i wait for it to fix or just drop it ? No updates about nsepython no where, no fixes.its been a long time

can you replace the index_history function with the below in rahu.py-

def index_history(symbol,start_date,end_date):
     data = "{'name':'"+symbol+"','startDate':'"+start_date+"','endDate':'"+end_date+"'}"
     data = {'cinfo': data}
     payload = requests.post('https://niftyindices.com/Backpage.aspx/getHistoricaldatatabletoString', headers=niftyindices_headers,  data=json.dumps(data)).json()

     payload = json.loads(payload["d"])
     payload=pd.DataFrame.from_records(payload)
     print(payload.head(1))
     return payload

Could you share the rahul.py link

Uff. So Long. I am intervening. Wait.

Sorted. Refer Getting an error - #7 by dexter

1 Like

@dexter Can you combine api from Niftyindices.com and NSEindia.com to fetch the historical data that have OHLC, Volume, Turnove, PE/PB, Div yield, Index name, date.

Niftyindices API doesn’t limit the date range but nseindia limit the date range for 1 year.

Need help on this.

But it also throws different data sturcture. So solving one request will create another problem. If you have other solution. tell me in detail. i will sort out.

@dexter i am also trying to figure it out but the issue is both website uses different index names as a code so it is difficult to catch and mege it all. So, i thought you may have some idea.

I am fully into commodity trading at the moment. So unless it picks my interest, I will not look at it (selfishly). But if you manage to find out fork a PR:)

Please help. It was working earlier to download the niftyindices data via api endpoint but now it is not. It is showing this error. Please fix this.

---------------------------------------------------------------------------

JSONDecodeError                           Traceback (most recent call last)

/usr/local/lib/python3.13/dist-packages/requests/models.py in json(self, **kwargs)
    975         try:
--> 976             return complexjson.loads(self.text, **kwargs)
    977         except JSONDecodeError as e:



5 frames


JSONDecodeError: Expecting value: line 1 column 2 (char 1)

During handling of the above exception, another exception occurred:


JSONDecodeError                           Traceback (most recent call last)

/usr/local/lib/python3.13/dist-packages/requests/models.py in json(self, **kwargs)
    978             # Catch JSON-related errors and raise as requests.JSONDecodeError
    979             # This aliases json.JSONDecodeError and simplejson.JSONDecodeError
--> 980             raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
    981 
    982     @property


JSONDecodeError: Expecting value: line 1 column 2 (char 1)