An unofficial API service for Nepal Stock Exchange (NEPSE) that provides real-time market data through both REST and WebSocket endpoints.
- Real-time market data access
- Multiple data endpoints including:
- Price and Volume information
- Market Summary
- Live Market Data
- Top Gainers/Losers
- Company Details
- Sector-wise Information
- Index and Sub-indices
- Floorsheet Data
The project consists of two main servers:
-
REST API Server (
server.py
)- Built with FastAPI
- Provides HTTP endpoints for market data
- Runs on port 8000
- Supports CORS
- Uses uvicorn as the ASGI server
-
WebSocket Server (
socketServer.py
)- Provides real-time data streaming
- Runs on port 5555
- Supports bidirectional communication
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Start REST API server
python server.py
# Start WebSocket server
python socketServer.py
docker build -t nepseapi .
docker run -p 8000:8000 -p 5555:5555 nepseapi
You can directly use the Docker image from Docker Hub:
docker run -p 8000:8000 -p 5555:5555 surajrimal/nepseapi:latest
Alternatively, you can use the provided Docker Compose file. Clone the project or copy the docker-compose.yml
file and run:
docker-compose up -d
Base URL: http://localhost:8000
Endpoint | Description |
---|---|
/Summary |
Get market summary |
/PriceVolume |
Get price and volume data |
/LiveMarket |
Get live market data |
/TopGainers |
Get top gaining stocks |
/TopLosers |
Get top losing stocks |
/CompanyList |
Get list of all companies |
/NepseIndex |
Get NEPSE index data |
/Floorsheet |
Get floorsheet data |
/SupplyDemand |
Get market supply/demand data |
And many more endpoints available at the root URL (/
).
- Python 3.11+
- Dependencies:
- FastAPI
- uvicorn
- websockets
- httpx
This project uses an unofficial API client for NEPSE and must be used in accordance with NEPSE's terms and conditions.
The project supports multiple deployment configurations:
- Configuration available in
ecosystem.config.js
- Manages both REST and WebSocket servers
- Automated builds via GitHub Actions
- Multi-platform Docker image support
- Automated testing and deployment pipeline
This project is not affiliated with the official Nepal Stock Exchange (NEPSE). The author is not liable for any legal issues or damages resulting from the use of this API.
This project depends upon and is heavily inspired by NepseUnofficialApi. Thanks to the author basic-bgnr for open sourcing the project.