Skip to main content

nepse-data-api

Python library for Nepal Stock Exchange (NEPSE)

PyPI Python 3.8+ License: MIT API Reference

nepse-data-api is a Python library for accessing market data from the Nepal Stock Exchange. It handles authentication, token management, and data scrambling automatically.

✨ Features

  • ✅ 37 API Endpoints - Complete NEPSE data coverage (Live Market, Dividends, Corporate Actions, Floorsheets, OHLCV, Financials, etc.)
  • ✅ WASM Authentication - Secure, automated token generation and management
  • ✅ Smart Caching - Built-in caching layer (5700x faster for repeated requests)
  • ✅ Async Support - Full async/await support for high-concurrency applications
  • ✅ Validated Data - Accurate and reliable market information

🚀 Quick Start

pip install nepse-data-api
from nepse_data_api import Nepse

# Initialize
nepse = Nepse()

# Get live market data
stocks = nepse.get_stocks()
print(f"Total listed stocks: {len(stocks)}")

# Get market status
status = nepse.get_market_status()
print(f"Market is currently: {status['isOpen']}")

# Get top gainers
gainers = nepse.get_top_gainers(limit=5)
for stock in gainers:
    print(f"{stock['symbol']}: {stock['ltp']} ({stock['percentageChange']}%)")

📖 API Reference

Market Overview

# Market status (open/close)
status = nepse.get_market_status()

# Market summary (turnover, transactions)
summary = nepse.get_market_summary()

# Live NEPSE main index
index = nepse.get_nepse_index()

# Live sector sub-indices
sectors = nepse.get_sub_indices()

# Historical index data (OHLCV)
# Supports: "NEPSE", "Banking", "HydroPower", "all", etc.
history = nepse.get_index_history("nepse")
history_range = nepse.get_index_history("banking", start_date="2026-08-01", end_date="2026-09-01")
all_indices = nepse.get_index_history("all")

Stock Data

from datetime import date

# Live stock prices (all stocks)
stocks = nepse.get_stocks()

# Historical prices for a specific date (e.g., today)
today = date.today().strftime("%Y-%m-%d")
stocks = nepse.get_stocks(date=today)

# Specific security details
# Use security ID from company list
details = nepse.get_security_details(security_id)

# Historical chart data
# Fetch chart for a date range (YYYY-MM-DD)
chart = nepse.get_historical_chart(58, start_date="2026-01-01", end_date=today)

Top Performers

# Top gainers
gainers = nepse.get_top_gainers(limit=10)

# Top losers
losers = nepse.get_top_losers(limit=10)

# Top by turnover / trade / transaction
turnover = nepse.get_top_turnover()
trades = nepse.get_top_trade()
trans = nepse.get_top_transaction()

Dividends & Corporate Actions

# 1. Official dividend notices (with AGM date, book-close date, filing PDFs)
dividends = nepse.get_dividends("NABIL")  # alias: nepse.get_dividend("NABIL")

# 2. Structured dividend history table (Bonus share %, Cash dividend %, Right share %)
# Note: "Corporate actions" is the official NEPSE term for bonus/cash dividend history
history = nepse.get_dividend_history("NABIL")  # alias: nepse.get_corporate_actions("NABIL")

# AGM announcements
agm = nepse.get_agm("NABIL")

# Financial reports (Quarterly & Annual EPS, PE, Net Worth Per Share, Profit)
reports = nepse.get_financial_reports("NABIL")

Company Information

# Company news
news = nepse.get_company_news(symbol="NABIL")

# Company profile & Board of Directors
profile = nepse.get_security_profile("NABIL")
bod = nepse.get_board_of_directors("NABIL")

# Metadata
companies = nepse.get_company_list()
securities = nepse.get_security_list()

Market Capitalization

# Latest market cap (all recent business dates)
marcap = nepse.get_marcapbydate()

# Market cap for a specific business date
marcap = nepse.get_marcapbydate(date="2026-04-24")
# Returns: businessDate, marCap, senMarCap, floatMarCap, senFloatMarCap

Trading Data

# Market depth (Order Book)
depth = nepse.get_market_depth(symbol="NABIL")

# Floorsheet (Transactions)
floorsheet = nepse.get_floorsheet(symbol="NABIL")

# Daily trade statistics for a specific date
stats = nepse.get_daily_trade(date="2026-02-12")

⚡ Advanced Features

Caching

The library includes a built-in LRU caching layer to respect NEPSE's server load and improve performance.

# Customize cache TTL (default: 30s)
nepse = Nepse(cache_ttl=120, enable_cache=True)

# Force fresh data for a single request
stocks = nepse.get_stocks(use_cache=False)

# Manually clear cache
nepse.clear_cache()

Async Support

For web applications or high-frequency polling, use AsyncNepse.

import asyncio
from nepse_data_api import AsyncNepse

async def main():
    nepse = AsyncNepse()
    
    # Parallel fetching
    status, stocks = await asyncio.gather(
        nepse.get_market_status(),
        nepse.get_stocks()
    )
    print(status, len(stocks))

asyncio.run(main())

📊 Performance

Operation Fresh Request Cached Improvement
Market Status ~48ms ~0.01ms 5700x
Stock List ~180ms ~0.02ms 12000x
Top Gainers ~52ms ~0.01ms 5200x

📁 Project Structure

nepse-data-api/
├── README.md              # Documentation
├── LICENSE                # MIT License
├── setup.py               # Package config
└── nepse_data_api/        # Source code
    ├── __init__.py        # Exports
    ├── market.py          # NEPSE & AsyncNepse classes
    ├── security.py        # Token & Security utilities
    └── version.py         # Version info

📋 Changelog

See CHANGELOG.md for a detailed history of changes and new features.

🤝 Contributing

Contributions are welcome!

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

FOR EDUCATIONAL PURPOSES ONLY

This library interfaces with publicly accessible APIs from the Nepal Stock Exchange (NEPSE). It is not affiliated with, endorsed by, or connected to NEPSE in any official capacity.

  • Data Attribution: All data is the property of Nepal Stock Exchange Ltd.
  • No Warranty: The software is provided "as is", without warranty of any kind.
  • Use Responsibly: Please respect NEPSE's servers. The built-in caching is designed to prevent abuse; do not disable it unless necessary.
  • Not Financial Advice: Data retrieved via this library should not be the sole basis for financial decisions.

License: MIT License - See LICENSE for details.

Metadata

Release files for nepse-data-api 1.0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nepse-data-api 1.0.0.5
File Size Uploaded Provenance Actions
nepse_data_api-1.0.0.5.tar.gz 32.6 kB With provenance Details for nepse_data_api-1.0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nepse-data-api 1.0.0.5
File Interpreter ABI Platform Actions
nepse_data_api-1.0.0.5-py3-none-any.whl Python 3 none any Details for nepse_data_api-1.0.0.5-py3-none-any.whl

Total release size: 59.3 kB

Release files / nepse_data_api-1.0.0.5.tar.gz

Download URL nepse_data_api-1.0.0.5.tar.gz
Size 32.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ddb54d0c36105a02fa88ce52360bc17060f79c177672351577cd5673c093cacb
BLAKE2b-256 checksum
How to use checksums
c1f8138a8a83cd58eb598a9a63e44bf15bd6ce35e49771a722d25484fcb3cbfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / nepse_data_api-1.0.0.5-py3-none-any.whl

Download URL nepse_data_api-1.0.0.5-py3-none-any.whl
Size 26.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83954ebc6ba2b7aefa281ef738448544a02bfe8c000f8296522a53c4f3a8dbc4
BLAKE2b-256 checksum
How to use checksums
224d67f8450a39a072df7cb90be69e34ce83baf8bd6c29f3ff543c615eb14ac9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for nepse-data-api 1.0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nepse_data_api-1.0.0.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page