Free, open JSON API for Indian mutual fund NAV data β a self-hostable,
transparent implementation of the familiar mfapi.in-style endpoints, built
from the official AMFI India
NAV feeds.
- ~14,000 mutual fund schemes, all AMCs and categories
- Full historical NAV series with scheme metadata and ISINs
- No authentication, no API keys, JSON responses
- Daily ingestion via GitHub Actions (twice a day, IST)
- Live FastAPI service and a static JSON export for GitHub Pages / any CDN
- Documentation site, interactive API explorer, status page, Swagger UI
- MIT-licensed code; Docker-ready
This project is independent and is not affiliated with AMFI, SEBI, any AMC or mfapi.in. NAV data remains subject to AMFI's and the AMCs' terms.
- Architecture
- Quick start
- API
- Data pipeline
- Daily GitHub Actions workflow
- Static JSON mode (GitHub Pages)
- Deployment
- Configuration
- Project structure
- Development
- Data source & attribution
- License
AMFI India MF Data API repository
ββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββ
β NAVAll.txt β β pipeline/ β
β (latest NAVs) β daily β download β parse β SQLite β JSON β
β β ββββββββΊ β β
β NAVHistoryReport β β data/mfdata.db (indexed, WAL) β
β (historical, 30-day β β public/api/v1/ (static JSON export) β
β chunks) β β β
ββββββββββββββββββββββββ β app/ FastAPI βββΊ /api/v1/* β
β web/ docs, explorer, status β
βββββββββββββββββββββββββββββββββββββββββββββ
β
GitHub Actions ββ΄ββΊ GitHub Pages (static JSON)
The pipeline stores everything in SQLite for fast querying. The same rows are exported as per-scheme JSON files, so the project works with or without a server. The front-end automatically switches between live-API mode and static mode.
docker compose up -d --build- API: http://localhost:8000/api/v1/mf
- Docs: http://localhost:8000/docs
- Swagger: http://localhost:8000/api/docs
On first boot the container downloads the latest NAV file plus 365 days of
history (configurable). The database is kept in the mfdata volume.
python -m venv .venv
# Windows: .venv\Scripts\activate
source .venv/bin/activate
pip install -r requirements.txt
# 1. Download AMFI data (first run backfills 3 years; use a smaller number for a quick demo)
python -m pipeline sync --bootstrap-days 1095
# 2. Optional: export the static JSON tree
python -m pipeline export --out public
# 3. Run the API + documentation site
python -m pipeline serve --port 8000Open http://localhost:8000. The API is also mounted without the version
prefix for compatibility: /mf/125497/latest.
python -m pipeline sync --bootstrap-days 30 # small first run
python -m pipeline sync --full # force a full backfill
python -m pipeline sync --lookback-days 14 # re-check two weeks of corrections
python -m pipeline status # counts, freshness, integrity
python -m pipeline export --out public # static JSON tree
python -m pipeline serve --reload # development serverBase URL: /api/v1 (root-level aliases also work).
| Method | Path | Description |
|---|---|---|
GET |
/mf |
Scheme list; limit, offset, q, fund_house, category |
GET |
/mf/search?q= |
Case-insensitive search, prefix-ranked |
GET |
/mf/{code} |
Metadata + full NAV history, newest first |
GET |
/mf/{code}/latest |
Latest NAV for one scheme |
GET |
/mf/latest |
Latest NAV for every scheme |
GET |
/mf/{code}/meta |
Scheme metadata only |
GET |
/fund-houses |
Fund houses with scheme counts |
GET |
/fund-houses/{name}/schemes |
Schemes for a fund house |
GET |
/categories |
Scheme types/categories with counts |
GET |
/nav/{date} |
All NAVs published on a date |
GET |
/dates |
Recent NAV dates |
GET |
/stats |
Dataset counts and freshness |
GET |
/health |
Health check |
Date inputs accept YYYY-MM-DD, DD-MM-YYYY or DD-Mon-YYYY. Response dates
use DD-MM-YYYY; NAVs are fixed-point strings with five decimals.
curl "http://localhost:8000/api/v1/mf/125497/latest"
curl "http://localhost:8000/api/v1/mf/125497?startDate=2025-01-01&endDate=2025-12-31"
curl "http://localhost:8000/api/v1/mf/search?q=hdfc&limit=5"
curl "http://localhost:8000/api/v1/mf?fund_house=SBI%20Mutual%20Fund"
curl "http://localhost:8000/api/v1/nav/20-11-2026?limit=100"{
"meta": {
"fund_house": "SBI Mutual Fund",
"scheme_type": "Open Ended Schemes",
"scheme_category": "Equity Scheme - Small Cap Fund",
"scheme_code": 125497,
"scheme_name": "SBI Small Cap Fund - Direct Plan - Growth",
"isin_growth": "INF200K01T51",
"isin_div_reinvestment": null
},
"data": [{ "date": "20-11-2026", "nav": "210.02130" }],
"status": "SUCCESS"
}Full documentation is served at /docs, and the generated OpenAPI schema is at
/api/openapi.json. Swagger UI is at /api/docs.
Rate limiting: 120 requests/minute per IP by default (MFDATA_RATE_LIMIT,
MFDATA_RATE_WINDOW). CORS is open by default.
pipeline/amfi.py downloads and parses:
- Latest NAVs β
https://portal.amfiindia.com/spages/NAVAll.txt - Historical NAVs β
https://portal.amfiindia.com/DownloadNAVHistoryReport_Po.aspxin 30-day chunks (AMFI caps a request at 90 days)
Rows are normalised, de-duplicated on (scheme_code, date) and upserted into
SQLite:
schemesβ code, name, fund house, type, category, ISINs, latest NAVnav_historyβ(scheme_code, date) β nav, indexed by datemetaβ last sync, dataset dates, counts
The first run backfills MFDATA_BOOTSTRAP_DAYS (default 1,095 days). Later runs
re-download a small lookback window (default 7 days) to pick up corrections, plus
the complete latest NAV file.
pipeline/export_static.py writes the static API tree:
public/api/v1/
βββ mf.json # all schemes
βββ mf/latest.json # latest NAV for every scheme
βββ mf/125497.json # full history
βββ mf/125497/latest.json # latest for one scheme
βββ fund-houses.json
βββ categories.json
βββ dates.json
βββ stats.json
βββ meta.json
βββ index.json
Raw NAVAll snapshots are gzipped into data/raw/ with a configurable retention
window (default 90 days) for auditing.
.github/workflows/update-data.yml runs at 09:45 IST and 22:15 IST
(plus manual dispatch) and:
- Restores the SQLite database from the Actions cache.
- Installs dependencies and runs
python -m pipeline sync. - Exports the static API and copies the documentation site.
- Saves the database back to the cache and commits
data/status.json. - Uploads the
public/artifact and deploys GitHub Pages.
- Push this repository to GitHub.
- Settings β Pages β Build and deployment β Source: GitHub Actions.
- Actions β Update NAV data β Run workflow for the first run. A full three-year backfill can take a while and downloads several hundred MB from AMFI; later runs are incremental.
- Optional: protect the
mainbranch but allow thegithub-actions[bot]to push the status commit (or remove the commit step if you prefer).
The workflow needs the default GITHUB_TOKEN permissions declared in the file
(contents: write, pages: write, id-token: write).
If the database cache is evicted, the next run automatically performs a full bootstrap again.
scripts/build_site.py copies web/ into public/ and switches
assets/config.js to static mode. The same site then works without any server:
| Live API | Static file |
|---|---|
/api/v1/mf |
/api/v1/mf.json |
/api/v1/mf/search?q= |
filter /api/v1/mf.json client-side |
/api/v1/mf/{code} |
/api/v1/mf/{code}.json |
/api/v1/mf/{code}/latest |
/api/v1/mf/{code}/latest.json |
/api/v1/mf/latest |
/api/v1/mf/latest.json |
/api/v1/fund-houses |
/api/v1/fund-houses.json |
/api/v1/categories |
/api/v1/categories.json |
/api/v1/stats |
/api/v1/stats.json |
/api/v1/nav/{date} |
not available (use per-scheme files) |
The documentation site, search, explorer (with client-side date filtering) and status page all adapt automatically.
For a local static build:
python -m pipeline export --out public
python scripts/build_site.py --out public
python -m http.server 8080 --directory publicStatic exports of full history can be large (hundreds of MB for three years).
Use python -m pipeline export --out public --history-days 365 if you need a
smaller tree.
docker compose up -d --buildPut Nginx/Caddy in front for TLS. Schedule a daily sync on the host:
docker compose exec api python -m pipeline syncor run the included GitHub Actions workflow and pull the updated database.
- Build:
pip install -r requirements.txt - Start:
uvicorn app.main:app --host 0.0.0.0 --port $PORT - Persistent disk mounted at
/data; setMFDATA_DATA_DIR=/data - Run
python -m pipeline sync --bootstrap-days 365once (job or shell), or setMFDATA_AUTO_SYNC=1and use the Docker entrypoint.
Run the export + build steps and publish public/. No Python runtime is needed
at request time.
| Variable | Default | Purpose |
|---|---|---|
MFDATA_DATA_DIR |
./data |
Database and raw snapshots |
MFDATA_DB |
data/mfdata.db |
Explicit SQLite path |
MFDATA_BOOTSTRAP_DAYS |
1095 |
History depth for a fresh DB |
MFDATA_INCREMENTAL_DAYS |
7 |
Correction window on incremental runs |
MFDATA_CHUNK_DAYS |
30 |
History download chunk size (max 90) |
MFDATA_RAW_RETENTION_DAYS |
90 |
Keep compressed NAVAll snapshots for N days |
MFDATA_RATE_LIMIT |
120 |
Requests per window; 0 disables |
MFDATA_RATE_WINDOW |
60 |
Window in seconds |
MFDATA_CACHE_TTL |
300 |
Default Cache-Control max-age for API responses |
MFDATA_CORS_ORIGINS |
* |
Comma-separated allowed origins |
MFDATA_AUTO_SYNC |
1 |
Docker: sync automatically when DB is missing |
MFDATA_TITLE / MFDATA_VERSION |
MF Data API / 1.0.0 |
Branding |
Copy .env.example to .env for local use (the app reads environment
variables; it does not load .env automatically).
.
βββ app/ FastAPI application
β βββ main.py app factory, middleware, static site
β βββ routes.py all API endpoints
β βββ schemas.py Pydantic/OpenAPI models
β βββ middleware.py rate limit + cache headers
β βββ config.py runtime settings
β βββ deps.py errors and dependencies
βββ pipeline/ AMFI ingestion and storage
β βββ amfi.py download + parse NAVAll/history feeds
β βββ store.py SQLite schema, upserts, queries
β βββ sync.py daily sync orchestration
β βββ export_static.py static JSON export
β βββ config.py pipeline settings
β βββ dates.py date helpers
β βββ __main__.py `python -m pipeline` CLI
βββ web/ documentation site (no build step)
β βββ index.html landing page
β βββ docs.html full API documentation
β βββ explorer.html interactive request builder
β βββ status.html dataset/status page
β βββ assets/ CSS, JS, config, favicon
βββ scripts/build_site.py copy site + static config for Pages
βββ docker/entrypoint.sh Docker entrypoint with optional first sync
βββ tests/ parser, store, API, export tests
βββ .github/workflows/ daily data update + CI
βββ Dockerfile
βββ docker-compose.yml
βββ requirements.txt
pip install -r requirements-dev.txt
ruff check app pipeline tests scripts
pytest -qTests use small AMFI fixtures, so they run offline and do not touch the network.
The web UI has no build step β plain HTML/CSS/JS. Edit files in web/ and reload.
When served by FastAPI, /docs, /explorer, /status, /privacy and /terms
map to the corresponding HTML files.
- Latest NAVs: https://portal.amfiindia.com/spages/NAVAll.txt
- Historical NAVs: https://portal.amfiindia.com/DownloadNAVHistoryReport_Po.aspx
- AMFI NAV download page: https://www.amfiindia.com/net-asset-value/nav-download
AMFI is the official source of Indian mutual fund NAVs. Scheme names, categories, ISINs and NAV values are reproduced as published. The project is not affiliated with AMFI, SEBI or any asset management company. Verify data against the official source before using it for financial decisions.
Code: MIT. Data: subject to AMFI's and the AMCs' terms; attribution to AMFI India is required when redistributing.
Built by PeaBox Labs