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 = "https://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
響應示例
{
"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 = "https://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 = "https://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 = "https://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 = "https://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 = "https://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": "http://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 = "https://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 = "https://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 = "https://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 = "https://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/