by akfamily
HTTP API and MCP server for AKShare: fetch financial data from any programming language or AI assistant (Claude, Cursor)
# Add to your Claude Code skills
git clone https://github.com/akfamily/aktoolsLast scanned: 10/30/2026
{
"issues": [],
"status": "PASSED",
"scannedAt": "2026-10-30T10:43:47.104Z",
"npmAuditRan": true,
"pipAuditRan": true,
"promptInjectionRan": true
}See how aktools compares with popular alternatives.
aktools is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by akfamily. HTTP API and MCP server for AKShare: fetch financial data from any programming language or AI assistant (Claude, Cursor). It has 1,503 GitHub stars.
Yes. aktools passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.
Clone the repository with "git clone https://github.com/akfamily/aktools" and add it to your Claude Code skills directory (see the Installation section above).
aktools is primarily written in Python. It is open-source under akfamily on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh aktools against similar tools.
No comments yet. Be the first to share your thoughts!
From $49 · 30 days · terms & refunds
⚠️ Third-Party Software Notice
This skill is third-party open-source software developed and hosted independently on GitHub. SkillsLLM is an informational directory and does not control or maintain the underlying repository.
Any security checks, ratings, or warnings displayed by SkillsLLM are automated and limited in scope. They do not constitute a security certification or guarantee that the software is safe, error-free, or free from malicious code, vulnerabilities, compromised dependencies, or prompt-injection risks.
Review the source code, permissions, dependencies, and configuration before installing or running any third-party skill. Use is at your own risk. To the maximum extent permitted by applicable law, SkillsLLM is not liable for losses arising from third-party software.
Automated security scan — not a certification.
AKTools exposes AKShare's financial data as an HTTP API and an MCP server, so you can fetch it from any programming language or AI assistant.
AKTools 把开源财经数据接口库 AKShare 的一千多个接口变成两种开箱即用的服务:
两种方式背后是同一套接口目录、缓存和错误处理,按需选用即可。
AKTools 中文文档 | AKShare 数据字典 | 版本说明
第一次使用? HTTP API 请从 快速入门教程 开始,约 10 分钟即可完成从安装到下载 Excel 的完整流程;AI 助手请直接看下面的 在 AI 助手中使用。
pip install aktools
python -m aktools
然后在浏览器打开 http://127.0.0.1:8080/api/public/tool_trade_date_hist_sina,看到交易日历数据即表示成功。更多用法见下文的快速开始与调用规则。
先安装 uv,再把下面的配置加入 AI 助手的 MCP 配置文件,不需要事先安装 AKTools,也不需要手动启动服务:
{
"mcpServers": {
"aktools": {
"command": "uvx",
"args": ["--from", "aktools", "aktools-mcp"]
}
}
}
重启助手后,就可以直接提问,例如:
助手会通过 AKTools 提供的 3 个工具完成查询:search_interfaces 搜索接口、describe_interface 查看参数、get_data 获取数据。下面是在 Claude Code 中实际提问的过程(根据真实会话记录回放):

打开设置中的“开发者 → 编辑配置”,把上面的配置加入 claude_desktop_config.json,保存后重启 Claude Desktop。
claude mcp add aktools -- uvx --from aktools aktools-mcp
点击按钮一键添加:
也可以手动把上面的配置加入项目的 .cursor/mcp.json,或全局的 ~/.cursor/mcp.json。
已经用 python -m aktools 启动了服务,或者想让多台电脑共用一个服务时,可以让助手直接连接 http://127.0.0.1:8080/mcp,例如:
claude mcp add --transport http aktools http://127.0.0.1:8080/mcp
第一次启动时 uvx 需要下载 AKShare 等依赖(约 150 MB),可能需要几分钟。配置、局域网访问与排障详见 AI 助手(MCP)文档。
python -m aktools 一行命令启动服务,无需编写任何代码/api/public/<接口名> 直接访问,AKShare 新增接口后升级即可使用/api/interfaces 列出全部接口并支持按关键词搜索,每个接口的参数、默认值和说明都能直接查询_format=csv 或 _format=xlsx 即可把数据下载为 CSV 或 Excel 文件/docs 即可在线查看和调试接口AKTools 要求 Python 3.11 及以上(64 位),运行环境要求与 AKShare 安装指导 一致。
pip install aktools
AKShare 的数据接口会随上游网站的变化频繁更新,遇到问题时请先把两者都升级到最新版:
pip install akshare aktools --upgrade -i https://pypi.org/simple
启动服务:
python -m aktools
浏览器打开以下地址:
| 地址 | 说明 |
|---|---|
http://127.0.0.1:8080/ |
主页,展示简要的使用说明 |
http://127.0.0.1:8080/docs |
接口导览,可在线调试 |
http://127.0.0.1:8080/version |
当前与最新的 AKShare、AKTools 版本 |
http://127.0.0.1:8080/api/interfaces?q=历史行情 |
按关键词搜索接口 |
http://127.0.0.1:8080/api/interfaces/stock_zh_a_hist |
查看接口的参数、默认值和说明 |
http://127.0.0.1:8080/api/public/tool_trade_date_hist_sina |
连通性测试(新浪交易日历,无需参数且较为稳定) |
http://127.0.0.1:8080/api/public/stock_zh_a_hist?symbol=600000 |
带参数获取数据 |
启动参数:
| 参数 | 简写 | 默认值 | 说明 |
|---|---|---|---|
--host |
-H |
127.0.0.1 |
监听地址,需要局域网或其他机器访问时设置为 0.0.0.0 |
--port |
-P |
8080 |
监听端口 |
--auto |
-A |
关闭 | 启动后自动打开浏览器 |
--cache-ttl |
— | 60 |
结果缓存的有效期(秒),同一接口、同样参数在有效期内直接返回上次的数据,0 为关闭 |
--akshare-cache-clear |
— | 3600 |
清空 AKShare 内部缓存的间隔(秒),避免板块名称等数据一直不更新,0 为关闭 |
--proxy |
— | 不设置 | 访问上游数据源使用的代理,如 http://127.0.0.1:7890;不设置时沿用 HTTP_PROXY 等环境变量 |
--timeout |
— | 60 |
访问上游数据源的读取超时(秒),连接超时固定为 10 秒 |
--token |
— | 不设置 | 访问令牌,设置后数据接口与 /mcp 需要携带令牌,多个令牌用逗号分隔,详见 访问令牌 |
--version |
-v |
— | 查看 AKTools 版本 |
例如:python -m aktools --port 8888 --auto 会在 8888 端口启动并自动打开浏览器。需要让局域网内的其他机器访问时,加上 --host 0.0.0.0,其他机器通过 http://<本机 IP>:8888 访问;0.0.0.0 只表示监听所有网卡,不能当作访问地址在浏览器中打开。
AKTools 本身不加工数据,只负责把 HTTP 请求翻译成对 AKShare 接口的调用:
GET /api/public/{接口名}?{参数1}={值1}&{参数2}={值2}
↓
akshare.{接口名}(参数1="值1", 参数2="值2")
/api/interfaces?q=关键词 搜索接口,通过 /api/interfaces/{接口名} 查看参数说明,详细的数据说明请查阅 AKShare 数据字典。?symbol=600000&period=weekly;不传的参数使用 AKShare 接口的默认值。"2024-01-25T00:00:00.000"。_format=csv 或 _format=xlsx,数据会以 {接口名}.csv 或 {接口名}.xlsx 文件下载,例如 /api/public/stock_zh_a_hist?symbol=000001&_format=xlsx。CSV 为带 BOM 的 UTF-8 编码,可以直接用 Excel 打开。请求失败时返回 {"error": "错误信息"},状态码含义如下:
| 状态码 | 含义 | 处理建议 |
|---|---|---|
200 |
成功 | — |
401 |
服务启用了访问令牌,但请求没有携带令牌或令牌不正确 | 在请求头加上 Authorization: Bearer <令牌>,或在网址中加上 _token=<令牌> |
400 |
参数名或参数值不合法,_format 取值不支持,或数据行数超过 Excel 上限 |
对照 /api/interfaces/{接口名} 检查参数;_format 改用 json、csv 或 xlsx,数据过大时改用 csv |
404 |
接口名不存在,或接口调用出错 | 升级 AKShare,并对照 /api/interfaces/{接口名} 检查接口名和参数 |
429 |
上游数据源限制了访问频率 | 稍后重试,或调大 --cache-ttl 减少重复请求 |
502 |
无法访问上游数据源、上游返回错误,或上游页面改版导致解析失败 | 检查网络和代理设置,见 常见问题;解析失败时升级 AKShare |
以下示例均假设服务运行在 http://127.0.0.1:8080,请按实际地址和端口修改。
curl "http://127.0.0.1:8080/api/public/stock_zh_a_hist?symbol=000001&period=daily&start_date=20240101&end_date=20240131&adjust=qfq"
import pandas as pd
import requests
url = "http://127.0.0.1:8080/api/public/stock_zh_a_hist"
params = {
"symbol": "000001",
"period": "daily",
"start_date": "20240101",
"end_date": "20240131",
"adjust": "qfq",
}
r = requests.get(url, params=params, timeout=30)
r.raise_for_status()
df = pd.DataFrame(r.json())
print(df)
library(RCurl) # 需要先安装该包
library(jsonlite) # 需要先安装该包
options(warn = -1) # 去掉无参数请求时的 warning 信息
temp_df <- getForm(
uri = "http://127.0.0.1:8080/api/public/stock_zh_a_hist",
symbol = "000001",
period = "daily",
start_date = "20211109",
end_date = "20211209",
adjust = "hfq",
.encoding = "utf-8"
)
inner_df <- fromJSON(temp_df)
inner_df
api = 'http://127.0.0.1:8080/api/public/';
url = [api 'stock_zh_a_hist'];
options = weboptions('ContentType', 'json', 'CharacterEncoding', 'utf-8');
data = webread(url, 'symbol', '000001', 'period', 'daily', ...
'start_date', '20211109', 'end_date', '20211209', 'adjust', 'hfq', options);
data % MATLAB 无法显示中文字段名,可自行改为英文字段
依赖:reqwest(启用 blocking 与 json 特性)和 serde_json。
use reqwest::blocking;
use serde_json::Value;
const URL: &str = "http://127.0.0.1:8080/api/public";
fn main() -> Result<(), Box<dyn std::error::Error>> {
let params = [
("symbol", "000001"),
("period", "daily"),
("start_date", "20240125"),
("end_date", "20240126"),
("adjust", ""),
];
let resp = blocking::Client::new()
.get(format!("{URL}/stock_zh_a_hist"))
.query(¶ms)
.send()?;
if resp.status().is_success() {
let data: Value = resp.json()?;
pr