npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nse-js

v0.0.9

Published

An unofficial Node.js API for NSE India stock exchange

Downloads

482

Readme

nse-js

nse-js is a Node.js library for fetching data from the National Stock Exchange (NSE) of India. It provides various methods to retrieve market data, circulars, option chains, corporate actions, and more.

[!IMPORTANT] This module is not yet ready for production use as it's not tested on production environment.

Installation

npm install nse-js

API limits

All requests through NSE are rate limited or throttled to 3 requests per second. This allows making large number of requests without overloading the server or getting blocked.

  • If downloading a large number of reports from NSE, please do so after-market hours (Preferably late evening).
  • Add an extra 0.5 - 1 sec sleep between requests. The extra run time likely wont make a difference to your script.
  • Save the file and reuse them instead of re-downloading.

Usage

const { NSE, Extras } = require('nse-js');
const nse = new NSE();
const ex = new Extras("./");

Methods

status()

Get market status.

nse.status().then(data => console.log(data));

circulars(deptCode, fromDate, toDate)

Get NSE circulars.

  • deptCode (optional): Department code.
  • fromDate (optional): Start date.
  • toDate (optional): End date.
nse.circulars().then(data => console.log(data));

blockDeals()

Get block deals.

nse.blockDeals().then(data => console.log(data));

fnoLots()

Get the lot size of FnO stocks.

nse.fnoLots().then(data => console.log(data));

optionChain(symbol)

Get the option chain for a symbol.

  • symbol: Symbol code.
nse.optionChain('nifty').then(data => console.log(data));

maxpain(optionChain, expiryDate)

Get the max pain strike price.

  • optionChain: Option chain data.
  • expiryDate: Expiry date.
nse.maxpain(optionChain, new Date()).then(data => console.log(data));

compileOptionChain(symbol, expiryDate)

Compile the option chain for a symbol.

  • symbol: Symbol code.
  • expiryDate: Expiry date.
nse.compileOptionChain('nifty', new Date()).then(data => console.log(data));

advanceDecline()

Get advance decline data.

nse.advanceDecline().then(data => console.log(data));

holidays(type)

Get NSE holidays.

  • type: Type of holiday (trading or clearing).
nse.holidays('trading').then(data => console.log(data));

equityMetaInfo(symbol)

Get equity meta info.

  • symbol: Symbol code.
nse.equityMetaInfo('RELIANCE').then(data => console.log(data));

quote(symbol, type, section)

Get quote data.

  • symbol: Symbol code.
  • type: Type of quote (equity or fno).
  • section: Section of quote (trade_info).
nse.quote('RELIANCE').then(data => console.log(data));

equityQuote(symbol)

Get equity quote data.

  • symbol: Symbol code.
nse.equityQuote('RELIANCE').then(data => console.log(data));

gainers(data, count)

Get gainers data.

  • data: Data object.
  • count: Number of gainers to return.
nse.gainers(data).then(data => console.log(data));

losers(data, count)

Get losers data.

  • data: Data object.
  • count: Number of losers to return.
nse.losers(data).then(data => console.log(data));

listFnoStocks()

Get list of FNO stocks.

nse.listFnoStocks().then(data => console.log(data));

listIndices()

Get list of indices.

nse.listIndices().then(data => console.log(data));

listIndexStocks(index)

Get list of index stocks.

  • index: Index name.
nse.listIndexStocks('NIFTY 50').then(data => console.log(data));

listEtf()

Get list of ETFs.

nse.listEtf().then(data => console.log(data));

listSme()

Get list of SMEs.

nse.listSme().then(data => console.log(data));

listSgb()

Get list of SGBs.

nse.listSgb().then(data => console.log(data));

listCurrentIPO()

Get list of current IPOs.

nse.listCurrentIPO().then(data => console.log(data));

listUpcomingIPO()

Get list of upcoming IPOs.

nse.listUpcomingIPO().then(data => console.log(data));

listPastIPO(fromDate, toDate)

Get list of past IPOs.

  • fromDate: Start date.
  • toDate: End date.
nse.listPastIPO(new Date('2023-01-01'), new Date('2023-12-31')).then(data => console.log(data));

actions(segment, symbol, fromDate, toDate)

Get corporate actions.

  • segment: Segment name.
  • symbol: Symbol code.
  • fromDate: Start date.
  • toDate: End date.
nse.actions('equities', 'RELIANCE', new Date('2023-01-01'), new Date('2023-12-31')).then(data => console.log(data));

announcements(index, symbol, fno, fromDate, toDate)

Get corporate announcements.

  • index: Index name.
  • symbol: Symbol code.
  • fno: FNO flag.
  • fromDate: Start date.
  • toDate: End date.
nse.announcements('equities', 'RELIANCE', false, new Date('2023-01-01'), new Date('2023-12-31')).then(data => console.log(data));

boardMeetings(index, symbol, fno, fromDate, toDate)

Get board meetings.

  • index: Index name.
  • symbol: Symbol code.
  • fno: FNO flag.
  • fromDate: Start date.
  • toDate: End date.
nse.boardMeetings('equities', 'RELIANCE', false, new Date('2023-01-01'), new Date('2023-12-31')).then(data => console.log(data));

equityBhavcopy(date, folder)

Get equity bhavcopy.

  • date: Date.
  • folder: Folder path.
ex.equityBhavcopy(new Date(), './downloads').then(data => console.log(data));

deliveryBhavcopy(date, folder)

Get delivery bhavcopy.

  • date: Date.
  • folder: Folder path.
ex.deliveryBhavcopy(new Date(), './downloads').then(data => console.log(data));

fnoBhavcopy(date, folder)

Get FNO bhavcopy.

  • date: Date.
  • folder: Folder path.
ex.fnoBhavcopy(new Date(), './downloads').then(data => console.log(data));

prBhavcopy(date, folder)

Get PR bhavcopy.

  • date: Date.
  • folder: Folder path.
ex.prBhavcopy(new Date(), './downloads').then(data => console.log(data));

License

This project is licensed under the GPL v3 License.

Credits

This project is inspired by BennyThadikaran's python version of NSE API.