Index_history is not working

I am getting error while calling index_history api. I am using python 3.10 and 2.8 version of nsepython.

import nsepython
nsepython.index_history(‘NIFTY 50’, ‘2024-03-01’, ‘2024-03-14’)
Traceback (most recent call last):
File “/snap/pycharm-community/374/plugins/python-ce/helpers/pydev/pydevconsole.py”, line 364, in runcode
coro = func()
File “”, line 1, in
File “/home/gurvinder/.local/lib/python3.10/site-packages/nsepython/rahu.py”, line 748, in index_history
payload = json.loads(payload[“d”])
KeyError: ‘d’

can someone please help?

1 Like

nsepython.index_history(‘NIFTY 50’, ‘2024-03-01’, ‘2024-03-14’)

Why this?

Try

from nsepython import *

Still getting the error with this syntax.

1 Like

Put in Google Collab using nsepythonserver.
Try.
If you fail, share that collab link here, I will check.

line
755, in index_pe_pb_div
payload = json.loads(payload[“d”])
~~~~~~~^^^^^
KeyError: ‘d’

Keyerror. Hmm. It means it is returning blank data.
Have you updated NSEpython to its latest version?

yes updated the library. it was working fine before but stopped working since few days back.

from nsepython import *

symbol = “NIFTY 50”

start_date = “01-Mar-2011”

end_date = “07-Jun-2021”

print(index_pe_pb_div(symbol,start_date,end_date))

output:

line 755, in index_pe_pb_div
payload = json.loads(payload[“d”])
~~~~~~~^^^^^
KeyError: ‘d’

Unable to debug as it works fine for me surprisingly. Try the nsepythonserver in Google Collab, You will see it works.

Whats your stack

hi
could you share the working g colab file for the same ?

pfa of my g colab:

will give tomorrow in phone.