NSE India & BSE India Live API using NodeJs and CheerioJS

Hello All, recently I was studying about Indian stocks and Web development and i was wondering there is no API available for the developers for free to fetch stock data for their application development. So i decided to create a Free API to fetch stock market data from NSE India using web scraping method.

I choose NodeJS and Cheerio for this coz you can write this API in just few lines of code and yet variety of features in both the frameworks.

For beginners, NodeJS is a JavaScript run time environments, I recommend watching the below video by Brad Traversy to learn basics about NodeJS.

Watch in YouTube : Node.js Tutorial For Absolute Beginners

Also you can learn cheerio in their official website itself. Visit cheerio.js.org 

Okay let’s get into coding.

We need express framework, Cheerio and request to be installed in the node modules using npm.



Alright i did tried NSE india official webiste and it was completly dynamic and hard to scrape, so i used reddif which had a simple interface and easy access to data. No worries both give almost live data.

You can change the url variable from the below code to the given url’s or you can design the app to take different url’s as input, since the reddif website is designed simply that all the pages looks similar you can almost fetch the data from below url’s.

Or I will design the app to scrape all the pages using dynamic routes in my future updates, follow me on GitHub to get more updates on this project but for now i need to keep this as simple as possible.

Supported Links:

  • Nifty 50 – http://money.rediff.com/gainers/nse/daily/nifty
  • All NSE – http://money.rediff.com/gainers/nse/daily/groupall
  • Even any Reddif BSE Indices link
  • Almost you can use any of the links from – http://money.rediff.com/indices , since the reddif website is designed such a way you can almost scrape the data into Json data using the below link.
Feel Free to work around the code also support the project in Github if you’d like. Also comment if you have any doubts.
If you’re wondering how the output will be, here it is.