3 步拿到数据
快速开始
两种接入方式:一个 curl 直接调,或用官方 SDK 两行代码拿到 DataFrame。都不需要申请流程。
1拿到 Key
免费端点无需 Key 即可试。要全量能力 → 获取 Key(见定价)。
# 免费端点直接调(无需 Key)
curl "https://api.ashareapi.com/v1/quote?code=sh600667"2带上 Key 调接口
推荐 Authorization 头(密钥不进日志/历史);?key= 也支持,仅建议在浏览器里快速试
# 方式 A(推荐 —— 脚本/生产都用这个):请求头
curl -H "Authorization: Bearer ct-你的KEY" \
"https://api.ashareapi.com/v1/fund?code=sh600667"
# 方式 B(仅快速测试):URL 参数 —— 直接粘到浏览器就能看
curl "https://api.ashareapi.com/v1/fund?code=sh600667&key=ct-你的KEY"3看返回
统一 JSON 信封:ok / endpoint / tier / elapsed_ms / source / data
{
"ok": true,
"endpoint": "fund",
"tier": "pro",
"elapsed_ms": 862,
"source": "multi",
"data": { "main_net": "...", "lhb": [...], ... }
}用官方 SDK:两行代码拿到 DataFrame
Python 和 Node.js / TypeScript 都有官方包,返回结构与 REST 完全一致,可直接接进你的脚本、看板或策略代码。
Python
pip install ashareapifrom ashareapi import AShareAPI
cli = AShareAPI() # 免费端点无需 Key
df = cli.kline("sh600519", "day", 30)Node.js
npm install ashareapiimport { AShareAPI } from 'ashareapi'
const cli = new AShareAPI() // 免费端点无需 Key
const rows = await cli.kline('sh600519', 'day', 30)代码要带小写市场前缀
sh600519(沪)· sz000001(深)· bj920002(北交所)· hk00700(港股)· usAAPL(美股)。写成 600519、600519.SH 或大写 SH600519 都会返回空数据。
需要全量能力?
付费档最多解锁 94 个端点、单次最多 1212 根 K 线、不设单日上限。
错误码
出错时先看这张表 —— 大部分问题能自己解决。
| 码 | 含义 | 怎么办 |
|---|---|---|
| 401 | API Key 无效 | Key 拼错 / 已禁用 → 检查 Key;或未带 Key 调了付费端点 |
| 403 | 本 Key 今日已用过 N 个不同 IP | 触发 IP 维度反倒卖 → 换网络被误拦请联系我们重置 |
| 429 | 超出频率限制(每分钟) | 降频或加间隔;标准版 120 次/分 |
| 200 + ok:false | 数据源取数失败 | 已自动换下一个源,不扣次数;若持续请反馈(附 endpoint 与时间) |
401
API Key 无效
Key 拼错 / 已禁用 → 检查 Key;或未带 Key 调了付费端点
403
本 Key 今日已用过 N 个不同 IP
触发 IP 维度反倒卖 → 换网络被误拦请联系我们重置
429
超出频率限制(每分钟)
降频或加间隔;标准版 120 次/分
200 + ok:false
数据源取数失败
已自动换下一个源,不扣次数;若持续请反馈(附 endpoint 与时间)
接入指引
想看完整端点?
94 个端点的参数与 curl / Python / JS 示例,一页看全。