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
Still getting the error with this syntax.
1 Like
dexter
April 19, 2024, 1:57pm
4
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’
dexter
April 19, 2024, 1:58pm
6
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’
dexter
April 20, 2024, 5:39pm
8
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:
dexter
April 20, 2024, 8:16pm
10
will give tomorrow in phone.
Hi
any updates on the same ? or could you share the working colab. ?
dexter
April 22, 2024, 7:16pm
12
Wait. Haven’t reached home. I am hyper active person don’t worry. Will give tomorrow.
Hi
Any updates dear , your api work is great, would it take time
dexter
April 26, 2024, 2:02pm
14
Tried to see once. Your collab said I don’t have access. So I forgot afterwards. They may have changed something in middle.
Use this for meanwhile.
import requests
headers = {
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Language': 'en-US,en;q=0.9',
'Connection': 'keep-alive',
'Content-Type': 'application/json; charset=UTF-8',
'DNT': '1',
'Origin': 'https://niftyindices.com',
'Referer': 'https://niftyindices.com/reports/historical-data',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36',
'X-Requested-With': 'XMLHttpRequest',
'sec-ch-ua': '"Google Chrome";v="123", "Not:A-Brand";v="8", "Chromium";v="123"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
}
json_data = {
'cinfo': "{'name':'NIFTY 50','startDate':'01-Jan-2023','endDate':'26-Apr-2024'}",
}
response = requests.post(
'https://niftyindices.com/Backpage.aspx/getHistoricaldatatabletoString',
headers=headers,
json=json_data,
)
response.text
not working
{“Message”:“Object reference not set to an instance of an object.”,“StackTrace”:" at IISL.Backpage.getHistoricaldatatabletoString(String cinfo) in D:\\NseIndices\\Temp\\March07_2024_LiveBackup\\Nifty Indices New\\Backpage.aspx.cs:line 364",“ExceptionType”:“System.NullReferenceException”}
i miss your api man , plz fix it
dexter
May 21, 2024, 9:39am
16
Tonight. Tonight. I promise. I am just busy with India Surf festival, Matribhasa project and a fuckup that happened in my family.
1 Like
O_O , o_o , õ_ō , aaj milegi
dexter
June 5, 2024, 8:36pm
18
Been sleeping for 2-4 hours a day for last two weeks due to work pressure. Please forgive me. Rest assured. its on my head.
1 Like
dont be sorry bro, please take your time and take care. Would love to see your Finest art in the industry working again. Missing it already.
I’m still getting the same error, what am i doing wrong? Please find the screenshot for reference.