fund-api
v1.2.1
Published
Fund market data API for Node.js and TypeScript
Maintainers
Readme
fund-api 是一个零运行时依赖的基金行情工具,支持 Node.js、浏览器、CLI 和 MCP。默认使用 funds.auto,自动从可用数据源获取基金数据。
支持使用方式
特性
- Node.js / Browser bundler API + TypeScript 类型
- CLI 查询基金净值、历史净值和搜索基金
- MCP tools 给 AI 客户端直接调用基金接口
- 默认自动数据源:
funds.auto - 指定数据源:
funds.tencent - 支持基金代码格式,例如
110022 - 零运行时依赖
Node.js
安装
Node.js 环境要求 >=18。
npm install fund-api使用
import { funds } from "fund-api";
const fund = await funds.auto.getFund("110022");
const list = await funds.auto.getFunds(["110022", "000001"]);
const history = await funds.auto.getNavHistory("110022");
const results = await funds.auto.searchFunds("易方达消费");浏览器
引用
<script src="https://cdn.jsdelivr.net/npm/fund-api/dist/browser/fund-api.iife.min.js"></script>使用
<script>
FundApi.funds.auto.getFund("110022").then(console.log);
FundApi.funds.auto.getFunds(["110022", "000001"]).then(console.log);
FundApi.funds.auto.getNavHistory("110022").then(console.log);
FundApi.funds.auto.searchFunds("易方达消费").then(console.log);
</script>浏览器示例:GitHub Pages
CLI
npx fund-api get-fund 110022
npx fund-api get-funds 110022 000001
npx fund-api get-nav-history 110022
npx fund-api search-funds 易方达消费MCP
把 fund-api 接到支持 MCP 的 AI 客户端:
{
"mcpServers": {
"fund-api": {
"command": "npx",
"args": ["-y", "fund-api", "mcp"]
}
}
}内置工具:get_fund、get_funds、get_nav_history、search_funds。
数据源
内置腾讯基金数据源,默认由 funds.auto 自动处理。
| 数据源 | 用法 | 能力 |
| --- | --- | --- |
| 自动 | funds.auto | 单只基金、批量基金、历史净值、搜索 |
| 腾讯 | funds.tencent | 单只基金、批量基金、历史净值、搜索 |
文档
| 文档 | 内容 | | --- | --- | | API 使用 | TypeScript API、数据结构、浏览器使用 | | CLI 使用 | 命令、参数、输出 | | MCP 使用 | MCP 客户端配置和工具列表 | | 项目架构 | 目录结构、provider 工厂、解析和错误模型 | | 开发指南 | 本地开发、测试、发布前检查、新增数据源 | | API 监控 | 定时检查第三方数据源并更新状态徽章 |
免责声明
fund-api 使用第三方公开基金接口作为数据来源,不保证数据的准确性、完整性、实时性或持续可用性。本项目不提供投资建议,任何交易或投资决策都应由你自行判断。商业、高频或生产使用前,请自行确认第三方数据源的服务条款、授权范围和合规要求。
License
MIT
