GEThistorical-kline
历史K线查询
全球历史K线行情查询(按时间段):股票/外汇/期货/贵金属/加密货币/股指等,开高低收+成交量
接入文件
历史K线数据查询(按时间段),排序从开始时间往结束时间方向排。 周期是1,5,15分钟,返回date当日的数据。 周期是30分钟,1小时,返回date当日及前4日的全部数据。 周期是4小时,返回date当日及前14日的全部数据。 周期是日,返回date当月及前2个月的全部数据。 周期是周,返回date当年的全部数据 。接口输出的日周期数据只有最近2年,分钟周期数据只有最近5天(更多历史数据可申请打包下载)。
接入示例程式碼
提供 Shell、Python、Go、Java、PHP 等常見接入示例,便於直接接到現有專案裡。
Shell 示例
curl --request GET \
--url 'https://openapi.toolkk.com/v1/aliyunmarket-cmapi029045-query-comkm4v2' \
--header 'Content-Type: application/json' \
--header 'X-API-Key: YOUR_API_KEY' \
--data '{\n "symbol": "品种合约代码(查询连接 http://demo.konpn.com/symbols.shtml",\n "period": "取 1M,3M,5M,10M,15M,30M,1H,2H,3H,4H,D,W,M。周期是1,5,15分钟则返回date当日的数据。 周期是30分钟或1小时则返回...",\n "date": "日期,返回结果排序顺序。接口输出的日周期数据最多只有10年,1分钟周期数据只有最近30天,5分钟及小时周期最多180天",\n "withlast": "是否包含最新的一个动态k线数据,(填写1是,0否)"\n}'Python 示例
import os
import requests
url = "https://openapi.toolkk.com/v1/aliyunmarket-cmapi029045-query-comkm4v2"
payload = {
"symbol": "品种合约代码(查询连接 http://demo.konpn.com/symbols.shtml",
"period": "取 1M,3M,5M,10M,15M,30M,1H,2H,3H,4H,D,W,M。周期是1,5,15分钟则返回date当日的数据。 周期是30分钟或1小时则返回...",
"date": "日期,返回结果排序顺序。接口输出的日周期数据最多只有10年,1分钟周期数据只有最近30天,5分钟及小时周期最多180天",
"withlast": "是否包含最新的一个动态k线数据,(填写1是,0否)"
}
headers = {
"Content-Type": "application/json",
"X-API-Key": os.getenv("TOOLKK_API_KEY", "YOUR_API_KEY"),
}
response = requests.get(url, headers=headers, params=payload, timeout=30)
response.raise_for_status()
print(response.json())Go 示例
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
endpoint := "https://openapi.toolkk.com/v1/aliyunmarket-cmapi029045-query-comkm4v2"
payload := []byte("{\n \"symbol\": \"品种合约代码(查询连接 http://demo.konpn.com/symbols.shtml\",\n \"period\": \"取 1M,3M,5M,10M,15M,30M,1H,2H,3H,4H,D,W,M。周期是1,5,15分钟则返回date当日的数据。 周期是30分钟或1小时则返回...\",\n \"date\": \"日期,返回结果排序顺序。接口输出的日周期数据最多只有10年,1分钟周期数据只有最近30天,5分钟及小时周期最多180天\",\n \"withlast\": \"是否包含最新的一个动态k线数据,(填写1是,0否)\"\n}")
req, err := http.NewRequest("GET", endpoint, bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-API-Key", "YOUR_API_KEY")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}Java 示例
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class ToolkkExample {
public static void main(String[] args) throws Exception {
String payload = "{\n \"symbol\": \"品种合约代码(查询连接 http://demo.konpn.com/symbols.shtml\",\n \"period\": \"取 1M,3M,5M,10M,15M,30M,1H,2H,3H,4H,D,W,M。周期是1,5,15分钟则返回date当日的数据。 周期是30分钟或1小时则返回...\",\n \"date\": \"日期,返回结果排序顺序。接口输出的日周期数据最多只有10年,1分钟周期数据只有最近30天,5分钟及小时周期最多180天\",\n \"withlast\": \"是否包含最新的一个动态k线数据,(填写1是,0否)\"\n}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://openapi.toolkk.com/v1/aliyunmarket-cmapi029045-query-comkm4v2"))
.method("GET", HttpRequest.BodyPublishers.ofString(payload))
.header("Content-Type", "application/json")
.header("X-API-Key", "YOUR_API_KEY")
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}請求示例
{
"symbol": "品种合约代码(查询连接 http://demo.konpn.com/symbols.shtml",
"period": "取 1M,3M,5M,10M,15M,30M,1H,2H,3H,4H,D,W,M。周期是1,5,15分钟则返回date当日的数据。 周期是30分钟或1小时则返回...",
"date": "日期,返回结果排序顺序。接口输出的日周期数据最多只有10年,1分钟周期数据只有最近30天,5分钟及小时周期最多180天",
"withlast": "是否包含最新的一个动态k线数据,(填写1是,0否)"
}響應示例
{
"Code": 0,
"Msg": "",
"Obj": "1600854240,10452.6,10455.8,10456.2,10452.5,0,5.37;1600854180,10455.8,10452.6,10455.8,10452.6,0,5.08"
}請求欄位
以下欄位根據示例 JSON 自動提取,僅作接入參考。
| 欄位路徑 | 型別 | 示例值 |
|---|---|---|
| type | string | object |
| properties | object | {...} |
| properties.symbol | object | {...} |
| properties.symbol.type | string | string |
| properties.symbol.description | string | 品种合约代码(查询连接 http://demo.konpn.com/symbols.shtml |
| properties.period | object | {...} |
| properties.period.type | string | string |
響應欄位
以下欄位根據示例 JSON 自動提取,僅作接入參考。
| 欄位路徑 | 型別 | 示例值 |
|---|---|---|
| type | string | object |
| properties | object | {...} |
| properties.Code | object | {...} |
| properties.Code.type | string | number |
| properties.Code.example | number | 0 |
| properties.Msg | object | {...} |
| properties.Msg.type | string | string |
| properties.Msg.example |