Financial-API is a free, open source ai development platforms project written in TypeScript and released under MIT. It has 3,585 GitHub stars, 313 forks and 47 open issues, and was last pushed 3 days ago. On this registry it ranks #109 of 139 tracked projects in AI Development Platforms, with 5 head-to-head comparisons available.

What is Financial-API?

Financial-API is the official Tonghuashun (HiThink) A-share financial data service, an MIT-licensed TypeScript project that exposes Chinese stock market data through a REST API, a hosted MCP server, a hithink-finance CLI, a Python SDK, a local DuckDB database and an Agent Skill for AI agents, quantitative researchers and application developers.

What it is

Financial-API is a TypeScript codebase, distributed as an npm package and maintained by Tonghuashun (HiThink), that provides official A-share market data to software rather than to a terminal screen. It lives in the AI tooling and quantitative finance ecosystem: the CLI requires Node.js 22.12 or newer, the Python SDK requires Python 3.11 or newer, and the service exposes itself as MCP so that Claude, Cursor and Windsurf can call financial data directly. The repository is licensed under MIT and carries the topics a-share, china-stock-market, financial-data, mcp, duckdb, cli, rest-api, ai-agent, npm-package and quantitative-finance.

The concrete problem it solves is fragmented access. A single API key, stored as the user-level environment variable HITHINK_FINANCE_API_KEY, unlocks quotes, financial statements, indices, sectors, funds, futures and options across every supported entry point at once. Instead of wiring one integration for a research notebook, a second for an agent and a third for a production service, the same credential and the same data contracts serve the REST API, the hosted MCP server, the CLI, the Python SDK and the local marketdb store. For repeated historical work it replaces repeated remote queries with a DuckDB database built on the developer's own machine, complete with incremental synchronisation, adjustment calculation and file export.

Key capabilities

  • Unified access through one API key shared by the REST API, hosted MCP, hithink-finance CLI and Python SDK, with credentials readable from HITHINK_FINANCE_API_KEY or a user-level credentials.env.
  • Local marketdb built on DuckDB, supporting initialisation, synchronisation, validation, repair, SQL queries, forward and backward adjustment, and export.
  • A-share market data covering latest price and turnover snapshots, historical K-lines, indices and sectors with constituents, the trading calendar, and instrument lookup that resolves a name or keyword to a unique thscode.
  • Financial statements and metrics: income statement, balance sheet, cash flow statement and five categories of financial indicators, plus valuation snapshots for PE TTM/MRQ, PB MRQ, PS TTM and PCF TTM.
  • Tonghuashun specialty data including the limit-up and limit-down pool, the broken-limit pool, consecutive limit-up ladders, individual stock anomalies, popularity rankings, the Dragon and Tiger list, and call auction snapshots with short-term strength benchmarks.
  • Public fund and derivative coverage: fund profiles, companies, managers, financials, disclosed holdings, performance and exchange-traded ETF/LOF quotes, alongside public futures and options varieties, contracts, positions, warehouse receipts, basis, schedules, intraday and daily K-lines.
  • Market dumps that download full or incremental daily K and company action files, writing large results to disk so terminal output and agent context do not overflow.

Who uses it and how

  • AI agent users install the hithink-finance Skill, which lets the agent detect the current environment and choose between the API, MCP, CLI and Python SDK automatically; the README recommends the Skill as the first install for anyone unsure which method fits.
  • Quantitative researchers work from Python 3.11+ notebooks and research scripts, pulling data into local marketdb tables for backtesting, stock screening, factor research and SQL analysis over long histories.
  • Application teams embed the REST API into websites, mobile apps and internal company systems, since the HTTP interface carries no language dependency and suits any server-side stack.
  • Terminal-driven operators use the CLI for batch queries, downloads and structured exports, and reach for market dumps when a whole-market or long-range pull would otherwise overload an interactive session.
  • Credential handling is part of the workflow: keys belong in hidden input or environment variables, must never be echoed back by an agent, and must not be written into code, logs, public configuration or Git repositories.

Getting started

Create an API key in the key management console at fuyao.aicubes.cn, then install the recommended entry point with npx skills add HiThink-Tech/Financial-API --skill hithink-finance -g --yes. The Skill bundles the access-method selection, quick paths for API, MCP, CLI and Python, name-to-code disambiguation rules, the full API contract mirror, security requirements and large-result handling guidance.

How it compares

No comparable paid products or similar tools are named in the facts supplied for this entry, and the registry lists no direct alternative alongside it. On the available evidence Financial-API stands alone in this registry as an official exchange-market data service offered by the data vendor itself.

When to use it — and when not to

Adoption carries real operational weight: a self-hoster must run Node.js 22.12+ for the CLI and Python 3.11+ for the SDK, maintain a local DuckDB store, and keep synchronisation, validation and adjustment jobs healthy, while the underlying market data still comes from a hosted service that requires an API key. The public capability set explicitly excludes minute K-lines, tick data, overseas market data, macroeconomic data, news announcement full text and research reports, so anyone needing intraday tick-level or non-A-share coverage should look elsewhere, and the Tonghuashun AI client is not yet wired to this data source. The repository remains actively maintained, with its most recent push on 2026-09-15, 3,585 stars and 47 open issues.

project readme (upstream, from github) — read inline

同花顺金融数据服务

Website Docs Python Node.js

同花顺金融数据服务(hithink-finance) 是由同花顺官方提供和维护的 A股金融数据服务,面向 AI Agent、量化研究者和应用开发者。

通过一个统一的 API Key,即可查询 A股最新行情、集合竞价、财务报表、估值、指数、板块、公募基金、公开期货期权资料与行情、涨跌停、炸板、个股异动、热榜和龙虎榜等数据,并将数据接入 AI 工具、Python 研究脚本、量化程序或业务系统。

一站式同花顺官方金融数据能力,覆盖 API、MCP、CLI、Python SDK、本地数据库和 Agent Skill。

  • 官网:
  • 在线文档:
  • API Key 管理:
  • 同花顺AI客户端:了解并下载
  • 仓库文档中心:docs/

当前请使用本项目的 API、MCP、CLI、Python SDK 和 Agent Skill 接入金融数据。同花顺AI客户端尚未发布接入本项目数据源的版本,后续版本计划接入,敬请期待。


你可以用它做什么

  • 查询一只或多只 A股的最新价格、涨跌幅、成交额等行情数据。
  • 获取股票、指数和板块的历史 K 线,用于趋势分析和量化研究。
  • 查询上市公司的利润表、资产负债表、现金流量表和财务指标。
  • 批量查询 A 股最新市盈率、市净率、市销率和市现率估值快照。
  • 获取交易日历、公司行动、复权因子等基础研究数据。
  • 查询集合竞价快照、短期基准、涨跌停池、炸板池、连板天梯、个股异动、热榜和龙虎榜。
  • 查询公募基金资料、公司、经理、财务、持仓、业绩、公开资讯以及 ETF/LOF 场内行情。
  • 查询公开期货期权品种、合约、持仓、仓单、基差、日程、分时和日 K。
  • 下载全市场数据,为回测、选股、因子研究和 AI 分析准备数据。
  • 让 Claude、Cursor、Windsurf 等支持 MCP 或 Agent Skill 的工具直接调用金融数据。
  • 在本地构建 DuckDB 数据库,完成增量同步、SQL 查询、复权计算和文件导出。

30 秒了解

这是什么

同花顺官方面向 AI Agent、量化研究和开发者提供的 A股金融数据服务。

有什么数据

覆盖 A股行情、集合竞价、标的目录、公司行动、财务报表与指标、估值、交易日历、指数、板块、公募基金、公开期货期权、涨跌停、炸板、个股异动、热榜、龙虎榜和全市场数据文件。

怎么使用

可以通过 REST API、托管 MCP、hithink-finance CLI、Python SDK、本地 marketdb 或统一 Agent Skill 接入。

不知道选哪种方式

优先安装 hithink-finance Skill。Agent 会识别当前环境和任务,在 API、MCP、CLI 与 Python SDK 之间自动选择合适的能力。


按使用场景选择接入方式

你的需求 推荐方式 说明
想让 AI Agent 自动查询金融数据 hithink-finance Skill Agent 自动判断使用 API、MCP、CLI 或 Python SDK
想让 Claude、Cursor 等聊天工具快速接入 MCP 配置服务地址和 API Key 后即可在对话中调用
想在 Python、Notebook 中研究股票 Python toolkit/SDK 适合研究脚本、数据处理和自定义取数策略
想把数据接入网站、App 或公司系统 REST API 零依赖 HTTP 接入,适合任意编程语言和服务端系统
想通过终端批量查询、下载和导出数据 CLI 统一远端取数、本地数据库和结构化输出
想长期保存历史行情并用 SQL 研究 marketdb 在本地自动构建和维护 DuckDB 数据库
想获取全市场、长时间范围的大批量数据 CLI / Market Dumps 大结果落盘,避免终端和 Agent 上下文过载
关注后续免配置使用方式和更多数据能力 同花顺AI客户端 后续版本计划接入本项目数据源,敬请期待

数据能力概览

数据 / 能力 可以解决的问题 推荐入口
A股最新行情快照 查询单只、多只或全市场股票的最新价格与交易数据 CLI / API / MCP / Python
A股历史 K 线 获取股票历史走势,支持研究、回测和趋势分析 CLI / marketdb
公司行动与复权 查询分红、送转等公司行动,并生成前复权、后复权数据 CLI / marketdb
财务报表与财务指标 查询利润表、资产负债表、现金流量表和五类财务指标 CLI / API / MCP / Python
A 股估值快照 批量查询市盈率 TTM/MRQ、市净率 MRQ、市销率 TTM 和市现率 TTM CLI / API / MCP / Python
A 股集合竞价 批量查询竞价实时/终态快照与短期强弱基准 CLI / API / MCP / Python
标的目录 根据股票名称、代码或关键词查找唯一 thscode CLI / API / MCP / Python
交易日历 判断交易日、安排数据同步和回测时间 CLI / API / MCP / Python
指数与板块 查询指数和板块目录、成分股、行情及历史 K 线 CLI / API / MCP / Python
同花顺特色数据 获取涨跌停池、炸板池、连板、异动、热榜和龙虎榜 CLI / API / MCP / Python
公募基金 查询资料、公司、经理、财务、披露持仓、业绩、资讯和场内行情 CLI / API / MCP / Python
期货与期权 查询公开品种、合约、持仓、仓单、基差、日程与行情 CLI / API / MCP / Python
全市场数据导出 下载全量或增量日 K、公司行动等标准数据文件 CLI / Market Dumps
本地 DuckDB 完成数据初始化、同步、校验、修复、SQL 查询和导出 CLI / marketdb
后续客户端数据与分析 关注资金流向等更多数据与分析能力的后续接入进展 同花顺AI客户端(敬请期待)

分钟 K、tick、海外行情、宏观数据、新闻公告原文和研报目前不在公开能力范围内。请求未支持的数据时,应明确说明,不使用模拟数据或静态示例冒充真实结果。


快速开始

1. 获取统一 API Key

登录 同花顺金融数据服务官网,进入 API Key 管理 创建 Key。

API、MCP、CLI 和 Python 远端取数共用同一个 API Key。统一推荐保存为用户级环境变量 HITHINK_FINANCE_API_KEYhithink-finance Skill 也能读取用户级 credentials.env,具体路径与各平台配置命令见 Skill 的 CLI 安装说明

优先使用隐藏输入或环境变量。也可以把刚获取的 Key 交给 Agent 代为配置;Agent 不应复述 Key,并且只能写入用户级凭据来源,不能写入代码、日志、公开配置或 Git 仓库。


2. 优先安装 hithink-finance Skill

Skill 是 Agent 使用本项目的统一说明书,包含:

  • 接入方式选择;
  • API、MCP、CLI 和 Python 快速路径;
  • 股票名称与代码消歧规则;
  • 完整 API 契约镜像;
  • 安全与合规要求;
  • 大结果落盘和上下文控制规范。

请选择一种安装方式:

  1. 优先:通过 npx skills add 安装(推荐)

    npx skills add HiThink-Tech/Financial-API --skill hithink-finance -g --yes
    

    通过该方式安装后,Skill 会在每个 Agent 会话第一次使用时默认静默检查并更新自身;同一会话不重复检查,无更新或失败时不打扰当前任务。设置 HITHINK_FINANCE_NO_SKILL_UPDATE=1 可关闭自动更新;安装目录与追踪哈希不一致时不会执行。新版本从下一次 Agent 会话开始生效。

  2. 无网络条件:从 Skill Hub 安装

    将提示词发送给你的 AI 安装该 Skill:

    请根据 https://skillhub.cn/install/skillhub.md,安装 hithink-finance。
    

如无法使用以上安装方式,也可以把完整的 skills/hithink-finance/ 目录复制到 Agent 文档声明的 Skills 发现目录。

必须保留 references/,不要只复制 SKILL.md

安装完成后重新打开会话,可以直接描述需求,例如:

查询贵州茅台的最新行情,并分析近一年的涨跌幅、最大回撤和均线趋势。
获取沪深300当前成分股,并将结果保存为本地文件。
查询宁德时代最近四期利润表和主要盈利指标,注明报告期和数据来源。

3. CLI:人类与 Agent 的默认推荐

CLI 将远端取数、本地数据库、认证、统一 JSON 输出和大结果落盘整合到一个命令入口。

优先从 npm 安装:

npm install -g @hithink-tech/hithink-finance-cli

安装会无感地为本机已检测到的 Agent 同步 CLI 配套 Skills;后续 CLI 升级沿用已保存策略自动更新。默认各 Agent 通过目录链接共享一份内容,不会为未检测到的客户端创建目录。首次只指定部分目标时,在安装前设置环境变量:

$previous = $env:HITHINK_FINANCE_SKILLS_AGENTS
$env:HITHINK_FINANCE_SKILLS_AGENTS = 'codex,workbuddy'
try { npm install -g @hithink-tech/hithink-finance-cli } finally { $env:HITHINK_FINANCE_SKILLS_AGENTS = $previous }

后来新增 Agent 时直接追加,不会移除已有目标:

hithink-finance skills sync --agent claude-code --format json
hithink-finance skills status --format json

详细的支持目标、自定义目录、复制兼容模式、修复与移除规则见 CLI Skills 管理说明

CLI 配套 Skills 兜底安装

如果 npm 禁用了安装脚本,优先在 CLI 安装完成后运行 hithink-finance skills sync --repair --format json。如果 CLI 自动同步仍不可用,也可以只为实际使用的 Agent 安装 hithink-finance-cli/skills/ 下的 12 个领域 Skills:

npx skills add https://github.com/HiThink-Tech/Financial-API/tree/main/hithink-finance-cli/skills --skill '*' --agent codex --global --yes --full-depth

codex 替换为目标 Agent 的名称;需要多个 Agent 时重复传入 --agent。不要使用 --all,它会把 Skills 安装到该工具支持的全部 Agent 目录。

也可以 clone 仓库或下载 GitHub 源码压缩包,再把 hithink-finance-cli/skills/ 下每个 hithink-finance-* 完整目录直接复制到目标 Agent 的 Skills 发现目录。不要把外层 skills/ 整体嵌套进去,也不要只复制 SKILL.md;各 Skill 的 references/ 必须一并保留。常用 Agent 的目录映射及手工安装边界见 CLI 兜底安装说明

通过 npx skills 或手工复制的内容不属于 CLI 生命周期托管范围。以后如需改回 hithink-finance skills sync 管理,应先移除这些手工副本,否则 CLI 会将同名目录视为用户内容并保留、报告冲突。

国内用户可使用 npmmirror 镜像加速:

npm install -g @hithink-tech/hithink-finance-cli --registry=https://registry.npmmirror.com

安装完成后验证:

hithink-finance auth login
hithink-finance capabilities --format json
  • auth login:安全录入 API Key。
  • capabilities:查看此版本 CLI 支持的机器可读能力目录。
  • --format json:返回稳定、统一的 JSON 格式,方便程序或 Agent 继续处理。

通过 Skill 使用时,Agent 会先复用统一凭据,再通过 stdin 完成 CLI 登录;已有 CLI 凭据需要更新时使用 auth login --api-key-stdin --replace 原子替换,无需用户再次输入。CLI 仍将副本保存在自己的系统凭据库中,因此脱离 Skill 后也可独立使用。

常见命令:

# 根据代码或名称查找股票
hithink-finance symbol search --q 600519 --limit 5 --format json

# 查询最新行情
hithink-finance market snapshot --thscodes 600519.SH --format json

# 查询最近四期利润表
hithink-finance financials income --thscode 600519.SH --limit 4 --format json

# 初始化本地数据库
hithink-finance data init --format json

# 使用 SQL 查询本地前复权日线
hithink-finance db query \
  --sql "SELECT * FROM v_daily_qfq LIMIT 10" \
  --format json

仅在参与仓库开发或 npm 暂不可用时从源码验证:

cd hithink-finance-cli
npm ci --ignore-scripts
npm run build
node dist/cli/main.js capabilities --format json
node dist/cli/main.js doctor --format json

完整说明见 hithink-finance-cli/README.md


4. REST API:适合业务系统和自定义开发

REST API 通过标准 HTTP 请求提供数据,适合:

  • 接入网站、App 和后台服务;
  • 使用 Java、Go、JavaScript、Python 等任意语言;
  • 自定义数据获取和任务编排;
  • 将金融数据嵌入已有业务流程。

使用 curl 查询贵州茅台最新行情:

curl 'https://fuyao.aicubes.cn/api/a-share/prices/snapshot?thscodes=600519.SH' \
  -H 'X-api-key: <API_KEY>'

仓库内 REST API 契约入口:

docs/api/ 按业务域提供原子接口文档;正文从文档源同步,业务域首页帮助选择接口。端内能力在详情页标记并链接统一使用说明。


5. MCP:最快接入 Chat Bot 和 IDE

MCP 适合 Claude Desktop、Cursor、Windsurf 和其他支持 MCP 的客户端。

将以下六个托管端点配置到客户端,并使用 hithink-finance-* 作为服务名称:

{
  "mcpServers": {
    "hithink-finance-a-share": {
      "type": "http",
      "url": "https://fuyao.aicubes.cn/mcp/a-share",
      "headers": {
        "X-api-key": "${HITHINK_FINANCE_API_KEY}"
      }
    },
    "hithink-finance-a-share-index": {
      "type": "http",
      "url": "https://fuyao.aicubes.cn/mcp/a-share-index",
      "headers": {
        "X-api-key": "${HITHINK_FINANCE_API_KEY}"
      }
    },
    "hithink-finance-meta": {
      "type": "http",
      "url": "https://fu

readme truncated — read the full docs on github

Frequently asked questions

Is Financial-API free to use?

Financial-API is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does Financial-API do?

同花顺官方 A股金融数据服务,提供股票实时行情、历史行情、财务报表、指数、板块、涨停等数据,适用于 AI Agent、量化研究和应用开发,支持 API、MCP、CLI 和 Python。Official Tonghuashun (HiThink) A-share financial data service provi

What is Financial-API written in?

Financial-API is primarily written in TypeScript. Its source is publicly available at https://github.com/HiThink-Tech/Financial-API, and it has 3,585 GitHub stars.