2025 免费股票 API 合集:覆盖港美 A 股实时行情与历史数据
涵盖港、美、A 股实时与历史数据,开发者与投资者的必备指南
在当今的金融市场中,获取准确、及时的股票数据至关重要。无论是量化交易、投资分析还是开发金融应用,高质量的股票行情接口都能提供强有力的支持。本文将详细介绍一套全面的股票 API 接口,覆盖港股 API、美股 API、A 股数据等多种市场数据源。这些接口支持实时行情接口、港股历史数据、美股历史数据、美股行情数据、股票 tick数据,以及低延时数据 API,帮助开发者轻松集成股票接口和金融行情服务。所有接口均基于 RESTful 设计,并支持 WebSocket 推送,确保数据低延迟和高可用性。

这些 API 来源于可靠的数据提供商,支持全球多个交易所,包括香港(HK)、上海(SH)、深圳(SZ)、美国(US)等多个全球市场。以下将逐一介绍每个接口,包括详细的参数说明表格、Python 代码示例、入参示例和响应示例。注意:所有请求需在 headers 中携带"accept": "application/json"和"token: "your_token"(替换为您的实际 API 密钥)。
1. 股票 IPO 接口(GET /stock/ipo)
这个接口提供专业的股票 IPO信息,覆盖A 股数据、美股数据、港股 API等全球市场。实时获取新股申购代码、发行价格、中签率、上市日期等,助力打新策略和市场研究。
参数说明
| 参数名称 | 描述 | 必填 | 类型 | 示例值 |
|---|---|---|---|---|
| type | 产品类型 | 是 | string | upcoming |
| region | 市场代码 | 是 | string | HK |
Python 代码示例
import requests
url = "//api.itick.org/stock/ipo?type=upcoming®ion=HK"
headers = {
"accept": "application/json",
"token": "your_token"
}
response = requests.get(url, headers=headers)
print(response.text)
### 入参示例
`https://api.itick.org/stock/ipo?type=upcoming®ion=HK`
### 响应示例
```json
{
"code": 0,
"msg": "ok",
"data": {
"content": [
{
"dt": 1755820800000,
"cn": "Picard Medical Inc",
"sc": "PMI",
"ex": "NYSE",
"mc": "19.1M",
"pr": "3.50-4.50",
"ct": "US"
}
],
"page": 0,
"totalElements": 28,
"totalPages": 14,
"last": false,
"size": 2
}
}
2. 批量历史 K 线查询接口(GET /stock/klines)
批量获取多只股票的港股历史数据或美股历史数据,支持 OHLCV 字段,从分钟线到月线。适用于股票接口的批量下载和对比分析。
参数说明
| 参数名称 | 描述 | 必填 | 类型 | 示例值 |
|---|---|---|---|---|
| region | 市场代码 | 是 | string | HK |
| codes | 产品代码,多个用逗号隔开 | 是 | string | 700,9988 |
| kType | K 线类型(1:分钟,2:5 分钟,...10:月 K) | 是 | integer | 2 |
| limit | K 线数量 | 是 | integer | 5 |
| et | 截止时间戳(可选,默认当前) | 否 | number | 1741239000000 |
Python 代码示例
import requests
url = "//api.itick.org/stock/klines?region=HK&codes=700,9988&kType=2&limit=5"
headers = {
"accept": "application/json",
"token": "your_token"
}
response = requests.get(url, headers=headers)
print(response.text)
入参示例
https://api.itick.org/stock/klines?region=HK&codes=700,9988&kType=2&limit=5
响应示例
{
"code": 0,
"msg": null,
"data": {
"700": [
{
"tu": 56119888070.5,
"c": 534.5,
"t": 1741239000000,
"v": 104799385,
"h": 536,
"l": 534.5,
"o": 535
}
]
}
}
3. 实时报价接口(GET /stock/quote)
提供实时行情接口,包括最新价、涨跌幅等,适用于美股行情数据和港股 API的即时查询。
参数说明
| 参数名称 | 描述 | 必填 | 类型 | 示例值 |
|---|---|---|---|---|
| region | 市场代码 | 是 | string | HK |
| code | 产品代码 | 是 | string | 700 |
Python 代码示例
import requests
url = "//api.itick.org/stock/quote?region=HK&code=700"
headers = {
"accept": "application/json",
"token": "your_token"
}
response = requests.get(url, headers=headers)
print(response.text)
入参示例
https://api.itick.org/stock/quote?region=HK&code=700
响应示例
{
"code": 0,
"msg": null,
"data": {
"s": "700",
"ld": 567,
"o": 571,
"h": 572,
"l": 560.5,
"t": 1754554089000,
"v": 16940382,
"tu": 9595241622.71,
"ts": 0
}
}
4. 历史 K 线查询接口(GET /stock/kline)
获取单只股票的美股历史数据或港股历史数据,支持多周期 OHLC 数据,确保金融行情分析的准确性。
参数说明
| 参数名称 | 描述 | 必填 | 类型 | 示例值 |
|---|---|---|---|---|
| region | 市场代码 | 是 | string | HK |
| code | 产品代码 | 是 | string | 700 |
| kType | K 线类型(1:分钟,2:5 分钟,...10:月 K) | 是 | integer | 2 |
| limit | K 线数量 | 是 | integer | 10 |
| et | 截止时间戳(可选,默认当前) | 否 | number | 1741239000000 |
Python 代码示例
import requests
url = "//api.itick.org/stock/kline?region=HK&code=700&kType=2&limit=10"
headers = {
"accept": "application/json",
"token": "your_token"
}
response = requests.get(url, headers=headers)
print(response.text)
入参示例
https://api.itick.org/stock/kline?region=HK&code=700&kType=2&limit=10
响应示例
{
"code": 0,
"msg": null,
"data": [
{
"tu": 56119888070.5,
"c": 534.5,
"t": 1741239000000,
"v": 104799385,
"h": 536,
"l": 534.5,
"o": 535
}
]
}
5. 批量实时报价接口(GET /stock/quotes)
批量获取多只股票的实时行情接口,毫秒级延迟,适合股票 api 接口的批量监控。
参数说明
| 参数名称 | 描述 | 必填 | 类型 | 示例值 |
|---|---|---|---|---|
| region | 市场代码 | 是 | string | HK |
| codes | 产品代码,逗号隔开 | 是 | string | 700,9988 |
Python 代码示例
import requests
url = "//api.itick.org/stock/quotes?region=HK&codes=700,9988"
headers = {
"accept": "application/json",
"token": "your_token"
}
response = requests.get(url, headers=headers)
print(response.text)
入参示例
https://api.itick.org/stock/quotes?region=HK&codes=700,9988
响应示例
{
"code": 0,
"msg": null,
"data": {
"700": {
"s": "700",
"ld": 567,
"o": 571,
"h": 572,
"l": 560.5,
"t": 1754554089000,
"v": 16940382,
"tu": 9595241622.71,
"ts": 0
}
}
}
6. 股票信息接口(GET /stock/info)
获取股票基本信息,如公司简介、市值等,支持美股 API和A 股数据的查询。
参数说明
| 参数名称 | 描述 | 必填 | 类型 | 示例值 |
|---|---|---|---|---|
| type | 产品类型 | 是 | string | stock |
| region | 市场代码 | 是 | string | HK |
| code | 产品代码 | 是 | string | 700 |
Python 代码示例
import requests
url = "//api.itick.org/stock/info?type=stock®ion=HK&code=700"
headers = {
"accept": "application/json",
"token": "your_token"
}
response = requests.get(url, headers=headers)
print(response.text)
入参示例
https://api.itick.org/stock/info?type=stock®ion=HK&code=700
响应示例
{
"code": 0,
"msg": "ok",
"data": {
"c": "AAPL",
"n": "Apple Inc.",
"t": "stock",
"e": "NASDAQ",
"s": "Electronic Technology",
"i": "Telecommunications Equipment",
"l": "Apple Inc.",
"r": "USD",
"bd": "Apple, Inc. engages in the design...",
"wu": "//www.apple.com",
"mcb": 3436885784335,
"tso": 14840389413,
"pet": 35.3865799154784,
"fcc": "USD"
}
}
7. 实时盘口接口(GET /stock/depth)
提供股票 tick级别的实时盘口数据,包含买卖档位,适用于低延时数据 API。
参数说明
| 参数名称 | 描述 | 必填 | 类型 | 示例值 |
|---|---|---|---|---|
| region | 市场代码 | 是 | string | HK |
| code | 产品代码 | 是 | string | 700 |
Python 代码示例
import requests
url = "//api.itick.org/stock/depth?region=HK&code=700"
headers = {
"accept": "application/json",
"token": "your_token"
}
response = requests.get(url, headers=headers)
print(response.text)
入参示例
https://api.itick.org/stock/depth?region=HK&code=700
响应示例
{
"code": 0,
"msg": null,
"data": {
"s": "700",
"a": [
{
"po": 1,
"p": 567,
"v": 13400,
"o": 3
}
],
"b": [
{
"po": 1,
"p": 566.5,
"v": 24700,
"o": 5
}
]
}
}
8. 批量实时盘口接口(GET /stock/depths)
批量获取盘口数据,支持金融行情的并发查询。
参数说明
| 参数名称 | 描述 | 必填 | 类型 | 示例值 |
|---|---|---|---|---|
| region | 市场代码 | 是 | string | HK |
| codes | 产品代码,逗号隔开 | 是 | string | 700,9988 |
Python 代码示例
import requests
url = "//api.itick.org/stock/depths?region=HK&codes=700,9988"
headers = {
"accept": "application/json",
"token": "your_token"
}
response = requests.get(url, headers=headers)
print(response.text)
入参示例
https://api.itick.org/stock/depths?region=HK&codes=700,9988
响应示例
{
"code": 0,
"msg": null,
"data": {
"700": {
"s": "700",
"a": [...],
"b": [...]
}
}
}
9. 实时成交接口(GET /stock/tick)
逐笔股票 tick数据,低延迟推送,适用于美股数据监控。
参数说明
| 参数名称 | 描述 | 必填 | 类型 | 示例值 |
|---|---|---|---|---|
| region | 市场代码 | 是 | string | HK |
| code | 产品代码 | 是 | string | 700 |
Python 代码示例
import requests
url = "//api.itick.org/stock/tick?region=HK&code=700"
headers = {
"accept": "application/json",
"token": "your_token"
}
response = requests.get(url, headers=headers)
print(response.text)
入参示例
https://api.itick.org/stock/tick?region=HK&code=700
响应示例
{
"code": 0,
"msg": null,
"data": {
"s": "700",
"ld": 567,
"t": 1754554087000,
"v": 1134500
}
}
10. 批量实时成交接口(GET /stock/ticks)
批量股票 tick查询,支持多股并发。
参数说明
| 参数名称 | 描述 | 必填 | 类型 | 示例值 |
|---|---|---|---|---|
| region | 市场代码 | 是 | string | HK |
| codes | 产品代码,逗号隔开 | 是 | string | 700,9988 |
Python 代码示例
import requests
url = "//api.itick.org/stock/ticks?region=HK&codes=700,9988"
headers = {
"accept": "application/json",
"token": "your_token"
}
response = requests.get(url, headers=headers)
print(response.text)
入参示例
https://api.itick.org/stock/ticks?region=HK&codes=700,9988
响应示例
{
"code": 0,
"msg": null,
"data": {
"700": {
"s": "700",
"ld": 567,
"t": 1754554087000,
"v": 1134500
}
}
}
11. 股票 WebSocket 接口(wss://api.itick.org/stock)
通过 WebSocket 实现低延时数据 API,支持实时行情接口推送,包括 tick、quote、depth。
参数说明
WebSocket 连接使用 headers 携带 token。订阅参数通过 JSON 消息发送:
- ac:
"subscribe" - params:
"AAPL$US,TSLA$US"(产品代码$市场) - types:
"depth,quote"(类型)
Python 代码示例
import websocket
import json
import time
def on_message(ws, message):
print("Received:", message)
def on_open(ws):
print("Connected")
subscribe_msg = {
"ac": "subscribe",
"params": "AAPL$US",
"types": "tick,quote,depth"
}
ws.send(json.dumps(subscribe_msg))
ws = websocket.WebSocketApp("wss://api.itick.org/stock",
header={"token": "your_token"},
on_message=on_message,
on_open=on_open)
ws.run_forever()
入参示例
订阅消息:{"ac": "subscribe", "params": "AAPL$US,TSLA$US", "types": "depth,quote"}
响应示例
{
"code": 1,
"data": {
"s": "AAPL.US",
"ld": 225.215,
"v": 16742235,
"t": 1731689407000,
"type": "tick"
}
}
结语
以上股票 API 接口涵盖了从实时行情接口到历史数据的全面需求,适用于港股 API、美股 API、A 股数据等多种场景。如果您是开发者,这些股票接口将大大提升您的应用效率。建议根据实际需求选择订阅计划,希望这份精心整理的免费API合集,能为您的研究与开发带来真正的便利。
注:本文提供的代码示例仅供参考,实际使用请根据官方最新文档修改
参考文档:https://docs.itick.org/
GitHub:https://github.com/itick-org/

