K-line (Candlestick) Data
curl --request GET \
--url https://api.tickdb.ai/v1/market/kline \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.tickdb.ai/v1/market/kline"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.tickdb.ai/v1/market/kline', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tickdb.ai/v1/market/kline",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tickdb.ai/v1/market/kline"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.tickdb.ai/v1/market/kline")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tickdb.ai/v1/market/kline")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "success",
"data": {
"symbol": "700.HK",
"type": "stock",
"interval": "1h",
"klines": [
{
"time": 1773291600000,
"open": "545.5",
"high": "546.5",
"low": "541.5",
"close": "543.5",
"volume": "1549300",
"quote_volume": "842560983.33"
}
]
}
}通用行情接口
历史 K 线
获取已结束时间周期的历史 K 线数据。
GET
/
v1
/
market
/
kline
K-line (Candlestick) Data
curl --request GET \
--url https://api.tickdb.ai/v1/market/kline \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.tickdb.ai/v1/market/kline"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.tickdb.ai/v1/market/kline', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tickdb.ai/v1/market/kline",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tickdb.ai/v1/market/kline"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.tickdb.ai/v1/market/kline")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tickdb.ai/v1/market/kline")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "success",
"data": {
"symbol": "700.HK",
"type": "stock",
"interval": "1h",
"klines": [
{
"time": 1773291600000,
"open": "545.5",
"high": "546.5",
"low": "541.5",
"close": "543.5",
"volume": "1549300",
"quote_volume": "842560983.33"
}
]
}
}注意事项
- 本接口返回已结束周期的历史K线数据,数据已固定不会变化
- 适用于策略回测、技术指标计算、数据归档存储
- 若需获取当前周期内正在更新的K线,请使用实时K线:
/v1/market/kline/latest
支持的市场
外汇、贵金属、指数、美股、港股、A股、中国期货、加密货币 示例:- 外汇:EURUSD、GBPUSD、USDJPY
- 贵金属:XAUUSD、XAGUSD
- 指数:SPX、NDX、DJI
- 美股:AAPL.US、TSLA.US、MSFT.US
- 港股:700.HK、9988.HK、3690.HK
- A股:600519.SH、000001.SZ、920186.BJ
- 中国期货:BU2609、IC2606、AP8888
- 加密货币:BTCUSDT、ETHUSDT、ADAUSDT
请求参数
| 参数名 | 是否必须 | 描述 |
|---|---|---|
| symbol | 是 | 交易产品代码 |
| interval | 是 | K线周期,可选值:1m, 5m, 15m, 30m, 1h, 2h, 4h, 1d, 1w, 1M |
| limit | 否 | 返回记录数,默认100,最大1000 |
| start_time | 否 | 开始时间戳(毫秒) |
| end_time | 否 | 结束时间戳(毫秒) |
| type | 否 | 产品类型,可选。代码无歧义时无需传递;若返回 AMBIGUOUS_SYMBOL 错误,按提示传入对应值即可。可选值:stock、indices、crypto、forex、futures |
返回字段说明
| 字段 | 说明 |
|---|---|
| symbol | 交易产品 |
| type | 产品类型 |
| interval | K线周期 |
| klines | K线数据数组 |
| └─ time | K线时间戳(毫秒) |
| └─ open | 开盘价 |
| └─ high | 最高价 |
| └─ low | 最低价 |
| └─ close | 收盘价 |
| └─ volume | 成交量 |
| └─ quote_volume | 成交额,期货通常不返回 |
| └─ open_interest | 持仓量,仅期货返回 |
授权
查询参数
Trading symbol
示例:
"700.HK"
K-line interval
可用选项:
1m, 5m, 15m, 30m, 1h, 2h, 4h, 1d, 1w, 1M 示例:
"1h"
Number of records (default 100, max 1000)
必填范围:
1 <= x <= 1000示例:
100
Start timestamp in milliseconds
示例:
1703123456789
End timestamp in milliseconds
示例:
1703209856789
Symbol type, optional. Not required when the symbol is unambiguous; if the API returns an AMBIGUOUS_SYMBOL error, pass the value as indicated
可用选项:
stock, indices, crypto, forex, futures 示例:
"stock"
