Skip to main content

A Python library for accessing data from the National Stock Exchange (NSE) of India.

Project description

PNSEA - Python NSE API

Overview

PNSEA is a Python library for fetching data from the National Stock Exchange of India (NSE). It provides easy access to stock market data, options chains, insider trading reports, mutual fund data, and more.

Features

  • Fetch real-time equity data (CMP, historical data, market status, etc.).
  • Get insider trading reports, pledged data, and SAST data.
  • Retrieve option chain data for stocks and indices.
  • Fetch mutual fund insider data.
  • Autocomplete search queries for NSE symbols.
  • Endpoint tester for API debugging.

Installation

pip install pnsea

Usage

Initialize the NSE Instance

from pnsea import NSE

nse = NSE()

Fetch Equity Data

# Get current market price of SBIN
print(nse.equity.info("SBIN")['priceInfo']['lastPrice'])

# Fetch historical data
print(nse.equity.history("ESCORTS", "01-02-2025", "14-02-2025"))

# Get market status
print(nse.equity.market_status())

Fetch Insider Trading Data

# Get general insider trading data
print(nse.insider.insider_data())

# Get insider trading data with date range
print(nse.insider.insider_data(from_date="11-12-2023", to_date="14-02-2025"))

# Get insider trading data for a specific company
print(nse.insider.insider_data("SBIN"))

# Get insider trading data for a specific company with date range
print(nse.insider.insider_data("INFY", from_date="11-12-2023", to_date="14-02-2025"))

# Get pledged data for a single company
print(nse.insider.getPledgedData("ESCORTS"))

# Get SAST data for a single company
print(nse.insider.getSastData("ESCORTS"))

# Get SAST data for a single company with date range
print(nse.insider.getSastData("INFY", from_date="01-01-2024", to_date="01-02-2025"))

Options Expiry Dates

# All expiries from symbol
print(nse.options.expiry_dates("NIFTY"))

Fetch Option Chain Data

# Get option chain for NIFTY - all data
print(nse.options.option_chain("NIFTY")[0])

# Get option chain for NIFTY - by expiry date
print(nse.options.option_chain("NIFTY", expiry_date="06-Mar-2025")[0])

# Get option chain for NIFTY - by strike price
print(nse.options.option_chain("NIFTY", strike_price=22000)[0])

# Get option chain for NIFTY - by expiry date & strike price
print(nse.options.option_chain("NIFTY", expiry_date="06-Mar-2025", strike_price=22000)[0])

# Get option chain for NIFTY - All Expiries
print(nse.options.option_chain("NIFTY")[1])

# Get option chain for NIFTY - Underlying Value
print(nse.options.option_chain("NIFTY")[2])

Fetch Mutual Fund Data

#Get mutual fund insider data with date range
print(nse.mf.mf_insider_data(from_date="01-02-2025", to_date="02-02-2025"))

#Get mutual fund insider data by ISIN
print(nse.mf.mf_insider_data(isin="INF879O01027"))

#Get mutual fund insider data by symbol
print(nse.mf.mf_insider_data(symbol="PPFAS Mutual Fund"))

Autocomplete Search

# Search for NSE symbols
print(nse.autocomplete("Info"))

Author

Written by Anil Sardiwal

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pnsea-0.2.25.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pnsea-0.2.25-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file pnsea-0.2.25.tar.gz.

File metadata

  • Download URL: pnsea-0.2.25.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pnsea-0.2.25.tar.gz
Algorithm Hash digest
SHA256 f007a2c9a319f39a8260da83955ac4c363d35f6b88558923c049c9dbf7e44a21
MD5 bb475bb4df713d4ab23d09ebfb706a51
BLAKE2b-256 2bf04c5d8ae246fead06c007711ef2538bf61d54c54315c4e74dbee481148a5f

See more details on using hashes here.

File details

Details for the file pnsea-0.2.25-py3-none-any.whl.

File metadata

  • Download URL: pnsea-0.2.25-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for pnsea-0.2.25-py3-none-any.whl
Algorithm Hash digest
SHA256 31c1bb6f28b1efd5c832f8d59e7f03bdef8f056a1c2c7fa4e5a8e9a089d7df77
MD5 138d6f2017d84141facd4b5efd1783f4
BLAKE2b-256 8c759b8e416ef5afa7edf01091d6fc2ad209a0821b111fa4d0dc47e81c3f79f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page