A comprehensive package and API server for accessing equity/index details and historical data from the National Stock Exchange of India. This project provides both an NPM package for direct integration and a full-featured GraphQL/REST API server.
๐ Documentation | ๐ Examples
โ ๏ธ Prerequisites: Node.js 18+ required
npm install stock-nse-india
import { NseIndia } from "stock-nse-india";
const nseIndia = new NseIndia();
// Get all stock symbols
const symbols = await nseIndia.getAllStockSymbols();
console.log(symbols);
// Get equity details
const details = await nseIndia.getEquityDetails('IRCTC');
console.log(details);
// Get historical data
const range = {
start: new Date("2020-01-01"),
end: new Date("2023-12-31")
};
const historicalData = await nseIndia.getEquityHistoricalData('IRCTC', range);
console.log(historicalData);
# Clone and setup
git clone https://github.com/hi-imcodeman/stock-nse-india.git
cd stock-nse-india
npm install
# Start the server
npm start
๐ Server URLs:
npm install stock-nse-india
# or
yarn add stock-nse-india
npm install -g stock-nse-india
git clone https://github.com/hi-imcodeman/stock-nse-india.git
cd stock-nse-india
npm install
npm start
The project now includes a powerful GraphQL API for flexible data querying:
# Get equity information
query GetEquity {
equities(symbolFilter: { symbols: ["IRCTC", "RELIANCE"] }) {
symbol
details {
info {
companyName
industry
isFNOSec
}
metadata {
listingDate
status
}
}
}
}
# Get indices data
query GetIndices {
indices(filter: { filterBy: "NIFTY" }) {
key
index
last
variation
percentChange
}
}
The API includes schemas for:
Comprehensive REST endpoints with automatic Swagger documentation:
GET /
- Market statusGET /api/marketStatus
- Market status informationGET /api/glossary
- NSE glossaryGET /api/equity/:symbol
- Equity detailsGET /api/equity/:symbol/historical
- Historical dataGET /api/indices
- Market indicesGET /api-docs
- Interactive API documentationVisit http://localhost:3000/api-docs
for complete interactive API documentation powered by Swagger UI.
# Get help
nseindia --help
# Get market status
nseindia
# Get equity details
nseindia equity IRCTC
# Get historical data
nseindia historical IRCTC
# Get indices information
nseindia index
# Get specific index details
nseindia index "NIFTY AUTO"
# Pull and run from Docker Hub
docker run --rm -d -p 3001:3001 imcodeman/nseindia
# Or build locally
docker build -t nseindia . && docker run --rm -d -p 3001:3001 nseindia:latest
Image: imcodeman/nseindia
Registry: Docker Hub
# Server Configuration
PORT=3000
HOST_URL=http://localhost:3000
NODE_ENV=development
# CORS Configuration
CORS_ORIGINS=https://myapp.com,https://admin.myapp.com
CORS_METHODS=GET,POST,OPTIONS
CORS_HEADERS=Content-Type,Authorization,X-Requested-With
CORS_CREDENTIALS=true
getAllStockSymbols()
- Get all NSE stock symbolsgetData()
- Generic data retrievalgetDataByEndpoint()
- Get data by specific NSE API endpointsgetEquityDetails(symbol)
- Get equity informationgetEquityHistoricalData(symbol, range)
- Historical price datagetEquityIntradayData(symbol)
- Intraday trading datagetEquityOptionChain(symbol)
- Options chain datagetEquityCorporateInfo(symbol)
- Corporate informationgetEquityTradeInfo(symbol)
- Trading statisticsgetEquityStockIndices()
- Get all market indicesgetIndexHistoricalData(index, range)
- Index historical datagetIndexIntradayData(index)
- Index intraday datagetIndexOptionChain(index)
- Index options datagetCommodityOptionChain(symbol)
- Commodity options datagetGainersAndLosersByIndex(index)
- Top gainers and losersgetMostActiveEquities()
- Most actively traded stocksโ ๏ธ Prerequisites: Node.js 18+ required
# Clone repository
git clone https://github.com/hi-imcodeman/stock-nse-india.git
cd stock-nse-india
# Install dependencies
npm install
# Development mode with auto-reload
npm run start:dev
# Build project
npm run build
# Run tests
npm test
# Generate documentation
npm run docs
npm start
- Start production servernpm run start:dev
- Development mode with auto-reloadnpm run build
- Build TypeScript to JavaScriptnpm test
- Run test suite with coveragenpm run docs
- Generate TypeDoc documentationnpm run lint
- Run ESLint# Run all tests
npm test
# Run tests with coverage
npm test -- --coverage
# Run specific test file
npm test -- utils.spec.ts
We welcome contributions! Please see our contributing guidelines and feel free to submit issues and pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
โญ Star this repository if you find it helpful!
Generated using TypeDoc