nse-js

0.0.9 • Public • Published

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.

Package Sidebar

Install

npm i nse-js

Weekly Downloads

2

Version

0.0.9

License

GPL-3.0

Unpacked Size

28.1 kB

Total Files

8

Last publish

Collaborators

  • saurabh_udupi