NSE Website "Resource Not Found" Error

Hi

I am hitting below API to get OHLC values of Bank Nifty Futures

https://www.nseindia.com/api/historical/fo/derivatives?&symbol=BANKNIFTY&identifier=FUTIDXBANKNIFTY

I get "Resource Not Found "

However if I first visit www.nseindia.com website before hitting API link

then I get output.

Unable to understand the same.

Even I tried on cloud as well. If I hit API first on cloud getting same error as above but if I open NSE website on local machine browser and then hit API on cloud I get output on cloud.

Ideally there should not be any nexus between cloud and my local machine right?

Can you please help on the same.?

That’s called cookies. This issue is solved in the code of the API. You can inspect the code that it first visit nseindia website and then retain the cookies in the session.

There should be always be nexus. NSE blocks all server access straight using robots.txt

If you see my code, You will see the magic.

The process is You need to get the header cookies on visitng nseindia.com site.

Or You need to visit a page that is on frontend. Not direct Request API call pages. It checks if there is a cookie which already had previous shit.