MFapi Skill
Query Indian mutual fund data — NAV history, scheme info, search — using the free MFapi.in API.
Setup
No authentication or API keys required. The API is completely free and open.
Ensure curl and jq are installed:
CODEBLOCK0
What is an ISIN Code?
ISIN (International Securities Identification Number) is a 12-character alphanumeric code that uniquely identifies a security globally (e.g. INF200K01UT4). Indian mutual fund schemes have up to two ISINs:
- - isinGrowth — identifies the Growth option of the scheme
- isinDivReinvestment — identifies the IDCW (Dividend) Reinvestment option (may be
null)
ISIN codes are printed on CAS (Consolidated Account Statements), broker/demat platforms, and AMFI's website. They are stable identifiers — unlike scheme names, they don't change when a fund house rebrands.
Base URL
CODEBLOCK1
Data is updated 6× daily (10:05 AM, 2:05 PM, 6:05 PM, 9:05 PM, 3:09 AM, 5:05 AM IST).
Usage
Search schemes by name
CODEBLOCK2
List all schemes (paginated)
CODEBLOCK3
Get latest NAV for a scheme
CODEBLOCK4
Get NAV history for a scheme
CODEBLOCK5
Get NAV history with date range
CODEBLOCK6
Get latest NAV for all schemes
CODEBLOCK7
Response Formats
Latest NAV (/mf/{scheme_code}/latest)
CODEBLOCK8
Search (/mf/search?q=...)
CODEBLOCK9
Scheme list (/mf)
CODEBLOCK10
Endpoints Reference
| Method | Endpoint | Description | Parameters |
|---|
| GET | INLINECODE7 | Search schemes by name | INLINECODE8 (required) |
| GET |
/mf | List all schemes (paginated) |
limit (1–1000),
offset (default 0) |
| GET |
/mf/{scheme_code} | NAV history for a scheme |
startDate,
endDate (ISO 8601) |
| GET |
/mf/{scheme_code}/latest | Latest NAV for a scheme | — |
| GET |
/mf/latest | Latest NAV for all schemes | — |
Get Latest NAV by ISIN (Python)
The API doesn't support querying by ISIN directly. The scripts/get_nav.py script resolves ISIN → scheme code using a locally cached scheme list, then fetches the latest NAV.
How it works
- 1. Cache — Downloads the full scheme list (
/mf, ~37k schemes) to /tmp/mfapi-schemes.json. Refreshes automatically if the cache is missing or older than 24 hours. - Lookup — Searches
isinGrowth and isinDivReinvestment fields in the cache. If no match, refreshes the cache and retries. - Fetch — Uses the resolved scheme code to call
/mf/{scheme_code}/latest.
Usage
CODEBLOCK11
Example output
CODEBLOCK12
When multiple ISINs are passed, the output is a JSON array.
Notes
- - Dates in responses use
DD-MM-YYYY format; query params use ISO 8601 (YYYY-MM-DD) - NAV values are strings with 5-decimal precision
- Scheme codes can be found via the search or list endpoints, or from AMFI's website
- The
/mf endpoint returns all ~37,000 schemes; the Python script caches it locally at /tmp/mfapi-schemes.json to avoid repeated large fetches - Cache auto-refreshes on ISIN lookup miss or after 24 hours
- No rate-limit headers are published, but the API asks for fair usage
Examples
CODEBLOCK13
MFapi 技能
使用免费的 MFapi.in API 查询印度共同基金数据 — NAV 历史、方案信息、搜索。
设置
无需身份验证或 API 密钥。该 API 完全免费且开放。
确保已安装 curl 和 jq:
bash
Debian/Ubuntu
sudo apt install -y curl jq
macOS
brew install curl jq
什么是 ISIN 代码?
ISIN(国际证券识别编码)是一个 12 位字母数字代码,用于全球唯一标识证券(例如 INF200K01UT4)。印度共同基金方案最多有两个 ISIN:
- - isinGrowth — 标识方案的增值选项
- isinDivReinvestment — 标识 IDCW(股息)再投资选项(可能为 null)
ISIN 代码印在 CAS(综合账户报表)、券商/存管平台和 AMFI 网站上。它们是稳定的标识符 — 与方案名称不同,当基金公司更名时不会改变。
基础 URL
https://api.mfapi.in
数据每日更新 6 次(印度标准时间 10:05 AM、2:05 PM、6:05 PM、9:05 PM、3:09 AM、5:05 AM)。
使用方法
按名称搜索方案
bash
curl -s https://api.mfapi.in/mf/search?q=HDFC | jq .[] | {schemeCode, schemeName}
列出所有方案(分页)
bash
curl -s https://api.mfapi.in/mf?limit=100&offset=0 | jq .[] | {schemeCode, schemeName}
获取方案的最新 NAV
bash
curl -s https://api.mfapi.in/mf/125497/latest | jq {scheme: .meta.scheme_name, nav: .data[0].nav, date: .data[0].date}
获取方案的 NAV 历史
bash
curl -s https://api.mfapi.in/mf/125497 | jq {scheme: .meta.scheme_name, records: (.data | length)}
按日期范围获取 NAV 历史
bash
curl -s https://api.mfapi.in/mf/125497?startDate=2023-01-01&endDate=2023-12-31 | jq .data
获取所有方案的最新 NAV
bash
curl -s https://api.mfapi.in/mf/latest | jq .[:5]
响应格式
最新 NAV(/mf/{scheme_code}/latest)
json
{
meta: {
fund_house: HDFC Mutual Fund,
scheme_type: Open Ended Schemes,
scheme_category: Equity Scheme - Large Cap Fund,
scheme_code: 125497,
scheme_name: HDFC Top 100 Fund - Direct Plan - Growth,
isin_growth: INF179K01BB2,
isindivreinvestment: null
},
data: [
{
date: 26-10-2024,
nav: 892.45600
}
],
status: SUCCESS
}
搜索(/mf/search?q=...)
json
[
{
schemeCode: 125497,
schemeName: HDFC Top 100 Fund - Direct Plan - Growth
}
]
方案列表(/mf)
json
[
{
schemeCode: 125497,
schemeName: HDFC Top 100 Fund - Direct Plan - Growth,
isinGrowth: INF179K01BB2,
isinDivReinvestment: INF179K01BC0
}
]
端点参考
| 方法 | 端点 | 描述 | 参数 |
|---|
| GET | /mf/search | 按名称搜索方案 | q(必需) |
| GET |
/mf | 列出所有方案(分页) | limit(1–1000),offset(默认 0) |
| GET | /mf/{scheme_code} | 方案的 NAV 历史 | startDate,endDate(ISO 8601) |
| GET | /mf/{scheme_code}/latest | 方案的最新 NAV | — |
| GET | /mf/latest | 所有方案的最新 NAV | — |
通过 ISIN 获取最新 NAV(Python)
该 API 不支持直接通过 ISIN 查询。scripts/get_nav.py 脚本使用本地缓存的方案列表将 ISIN 解析为方案代码,然后获取最新 NAV。
工作原理
- 1. 缓存 — 将完整方案列表(/mf,约 37,000 个方案)下载到 /tmp/mfapi-schemes.json。如果缓存缺失或超过 24 小时,自动刷新。
- 查找 — 在缓存中搜索 isinGrowth 和 isinDivReinvestment 字段。如果没有匹配,刷新缓存并重试。
- 获取 — 使用解析出的方案代码调用 /mf/{scheme_code}/latest。
使用方法
bash
单个 ISIN
python3 scripts/get_nav.py INF200K01UT4
多个 ISIN
python3 scripts/get_nav.py INF200K01UT4 INF846K01DP8
示例输出
json
{
isin: INF200K01UT4,
scheme_code: 119800,
scheme_name: SBI Liquid Fund - DIRECT PLAN -Growth,
fund_house: SBI Mutual Fund,
category: Debt Scheme - Liquid Fund,
nav: 4277.67540,
date: 18-02-2026
}
当传入多个 ISIN 时,输出为 JSON 数组。
注意事项
- - 响应中的日期使用 DD-MM-YYYY 格式;查询参数使用 ISO 8601(YYYY-MM-DD)
- NAV 值为保留 5 位小数的字符串
- 方案代码可通过搜索或列表端点找到,或从 AMFI 网站获取
- /mf 端点返回所有约 37,000 个方案;Python 脚本将其本地缓存到 /tmp/mfapi-schemes.json,避免重复大量获取
- 缓存会在 ISIN 查找未命中或 24 小时后自动刷新
- 未公布速率限制标头,但 API 要求合理使用
示例
bash
查找所有 SBI 共同基金方案
curl -s https://api.mfapi.in/mf/search?q=SBI | jq .[].schemeName
获取已知方案的今日 NAV
curl -s https://api.mfapi.in/mf/119551/latest | jq .data[0]
比较一年内的 NAV
curl -s https://api.mfapi.in/mf/125497?startDate=2025-01-01&endDate=2025-12-31 \
| jq [.data[0], .data[-1]] | {latest: .[0], oldest: .[1]}
获取方案的基金公司和类别
curl -s https://api.mfapi.in/mf/125497/latest | jq .meta | {fund
house, schemecategory}
列出匹配Axis的前 10 个 Direct Plan Growth 方案
curl -s https://api.mfapi.in/mf/search?q=Axis \
| jq [.[] | select(.schemeName | test(Direct.*Growth))] | .[:10]
通过 ISIN 获取最新 NAV
python3 scripts/get_nav.py INF200K01UT4