I am hitting an error while calling the Result API. I was earlier using the older method nse_events() in the older version of nsepython and it was working fine but in the newer version of nsepython (2.6), both nse_events() & nse_results() throw an error.
ipdb> nse_**results()**
*** requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
ipdb> nse_**results**("equities","Others")
*** requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
ipdb> nse_**events()**
*** requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Anyone else having the same issue?
For now, I rolled back to older version that is working on my other machine using below command, and I am able to get events data again. I was earlier on v2.6
I thank you a lot. This is what happens in democracy. I had patched a code by someone in this forum and it worked for him and broke for 100 people lol. I am updating a new patch in nsepython. Install the latest version now.
from jugaad_data.nse import NSELive
n = NSELive()
tata_motors_price, mon100_etf = n.stock_quote(‘TATAMOTORS’)[‘priceInfo’][‘lastPrice’], n.stock_quote(‘MON100’)[‘priceInfo’][‘lastPrice’]
The error which I get is as follows
File “/home/viswayarasi/.conda/envs/dspy311_stocks/lib/python3.11/site-packages/jugaad_data/nse/live.py”, line 51, in get
return r.json()
^^^^^^^^
File “/home/viswayarasi/.conda/envs/dspy311_stocks/lib/python3.11/site-packages/requests/models.py”, line 978, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Same issue for me too. It seemed to work till last week (or last to last). But, is failing now.
Trying re-install if that solves problem. Will update post my observations.
I think NSE has updated its API with web-scrapping protection changes. I was reading it some time back about it. I tried reading the NSE API directly using python but it is throwing 401 each time (it used to work earlier).
@dexter : Could you please review if this function can be fixed.
@dexter Could you please share details on the workaround, so that folks can try it out themselves? I believe NSE has put restrictions on returning json object as part of response (API returns 200, but accessing json fails)