AllTick API Docs
服务状态
  • 欢迎
  • 接入流程
    • 流程说明
    • 行情地址说明
      • HTTP 行情 API 地址说明
      • Websocket 行情 API 地址说明
    • Token 申请
    • 接口限制说明
      • HTTP 接口限制
      • Websocket 接口限制
      • 错误码说明
    • 通用标准头说明
      • HTTP 通用标准头
      • Websocket 通用标准头
    • 产品 Code 列表
      • A股
      • 港股
      • 美股
      • 加密货币(数字币)
      • 商品(贵金属)
      • 外汇
  • REST API
    • HTTP 请求示例
    • HTTP接口API
      • GET 单产品历史K线查询(最高、最低、开盘、收盘价)
      • POST 批量查询产品最新2根K线(最高、最低、开盘、收盘价)
      • GET 最新盘口(最新深度、Order Book)查询
      • GET 最新成交价(最新tick、当前价、最新价)批量查询
      • GET 股票产品基础信息批量查询
      • 涨跌幅、休市、假期、涨停跌停、新股上市和退市
  • Websocket API
    • Websocket 请求示例
    • Websocket接口API
      • 最新成交价(实时逐笔Tick数据、当前价、最新价)批量订阅
      • 最新盘口(实时逐笔深度、Order Book)订阅
      • 取消报价订阅
      • 心跳
      • K线推送(不支持)
  • FAQs
    • 基础使用
      • AllTick 提供哪些类型的金融数据?
      • 如何获取AllTick的API密钥?
      • AllTick的数据更新频率是多少?
      • 如何在我的应用程序中集成AllTick的数据?
      • AllTick支持哪些编程语言进行API调用?
      • 我可以使用AllTick的数据进行商业用途吗?
      • 如何联系AllTick的客户支持?
      • AllTick的API有请求限制吗?
      • 如何报告数据问题或API故障?
      • AllTick提供实时数据还是延迟数据?
    • 订阅与账户管理
      • 如何注册AllTick账户?
      • AllTick有免费试用期吗?
      • 如何取消AllTick的订阅服务?
      • 我的订阅包括哪些服务?
      • 如何升级我的AllTick订阅计划?
      • 如何更改我的账户信息?
      • 我忘记了我的登录密码,该怎么办?
      • 如何保护我的AllTick账户安全?
      • 是否可以多人共享一个AllTick账户?
      • 我的订阅可以退款吗?
    • 数据使用与技术问题
      • 如何使用AllTick的WebSocket服务?
      • AllTick的API支持哪些数据格式?
      • 如何处理AllTick数据的高频更新?
      • 我在使用API时遇到了技术问题,该怎么解决?
      • 如何确保从AllTick接收的数据的准确性?
      • AllTick是否提供历史数据查询?
      • 如何限制我的数据使用量以避免超出订阅限制?
      • AllTick的API是否支持批量请求?
      • 如何获取特定金融市场的实时通知和警报?
      • AllTick是否提供数据分析和可视化工具?
由 GitBook 提供支持
在本页

这有帮助吗?

  1. REST API

HTTP 请求示例

上一页外汇下一页HTTP接口API

最后更新于2个月前

这有帮助吗?

/ 中文

package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

func http_example() {

	/*
		将如下JSON进行url的encode,复制到http的查询字符串的query字段里
		{"trace" : "go_http_test1","data" : {"code" : "700.HK","kline_type" : 1,"kline_timestamp_end" : 0,"query_kline_num" : 2,"adjust_type": 0}}

		特别注意:
		github: https://github.com/alltick/realtime-forex-crypto-stock-tick-finance-websocket-api
		token申请:https://alltick.co
		把下面url中的testtoken替换为您自己的token
		外汇,加密货币(数字币),贵金属的api址:
		https://quote.alltick.io/quote-b-api
		股票api地址:
		https://quote.alltick.io/quote-stock-b-api
	*/
	url := "https://quote.alltick.io/quote-stock-b-api/kline"
	log.Println("请求内容:", url)

	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		fmt.Println("Error creating request:", err)
		return
	}

	q := req.URL.Query()
	token := "testtoken"
	q.Add("token", token)
	queryStr := `{"trace":"1111111111111111111111111","data":{"code":"AAPL.US","kline_type":1,"kline_timestamp_end":0,"query_kline_num":10,"adjust_type":0}}`
	q.Add("query", queryStr)
	req.URL.RawQuery = q.Encode()
	// 发送请求
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		fmt.Println("Error sending request:", err)
		return
	}
	defer resp.Body.Close()

	body2, err := ioutil.ReadAll(resp.Body)

	if err != nil {

		log.Println("读取响应失败:", err)

		return

	}

	log.Println("响应内容:", string(body2))

}
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class HttpJavaExample {

    public static void main(String[] args) {

        try {

            /*
            Encode the following JSON into URL format and copy it to the query field of the HTTP request
            {"trace" : "java_http_test1","data" : {"code" : "700.HK","kline_type" : 1,"kline_timestamp_end" : 0,"query_kline_num" : 2,"adjust_type": 0}}
            Special Note:
            GitHub: https://github.com/alltick/realtime-forex-crypto-stock-tick-finance-websocket-api
            Token Application: https://alltick.co
            Replace "testtoken" in the URL below with your own token
            API addresses for forex, cryptocurrencies, and precious metals:
            https://quote.alltick.io/quote-b-api
            Stock API address:
            https://quote.alltick.io/quote-stock-b-api
            */
            String url = "http://quote.alltick.io/quote-stock-b-api/kline?token=testtoken&query=%7B%22trace%22%20%3A%20%22java_http_test1%22%2C%22data%22%20%3A%20%7B%22code%22%20%3A%20%22700.HK%22%2C%22kline_type%22%20%3A%201%2C%22kline_timestamp_end%22%20%3A%200%2C%22query_kline_num%22%20%3A%202%2C%22adjust_type%22%3A%200%7D%7D";

            URL obj = new URL(url);

            HttpURLConnection con = (HttpURLConnection) obj.openConnection();

            con.setRequestMethod("GET");

            int responseCode = con.getResponseCode();

            System.out.println("Response Code: " + responseCode);

            BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));

            String inputLine;

            StringBuffer response = new StringBuffer();

            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }

            in.close();

            System.out.println(response.toString());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
<?php

// Special Note:
// GitHub: https://github.com/alltick/realtime-forex-crypto-stock-tick-finance-websocket-api
// Token Application: https://alltick.co
// Replace "testtoken" in the URL below with your own token
// API addresses for forex, cryptocurrencies, and precious metals:
// https://quote.alltick.io/quote-b-ws-api
// Stock API address:
// https://quote.alltick.io/quote-stock-b-ws-api

$params = '{"trace":"1111111111111111111111111","data":{"code":"AAPL.US","kline_type":1,"kline_timestamp_end":0,"query_kline_num":10,"adjust_type":0}}';

$url = 'https://quote.alltick.io/quote-stock-b-api/kline?token=testtoken';
$method = 'GET';

$opts = array(CURLOPT_TIMEOUT => 10, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false);

/* Set specific parameters based on request type */
switch (strtoupper($method)) {
    case 'GET':
        $opts[CURLOPT_URL] = $url.'&query='.rawurlencode($params);
        $opts[CURLOPT_CUSTOMREQUEST] = 'GET';
        break;
    default:
}

/* Initialize and execute curl request */
$ch = curl_init();
curl_setopt_array($ch, $opts);
$data = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);

if ($error) {
    $data = null;
}

echo $data;
?>
import time
import requests
import json

# Extra headers
test_headers = {
    'Content-Type': 'application/json'
}

'''
# Special Note:
# GitHub: https://github.com/alltick/realtime-forex-crypto-stock-tick-finance-websocket-api
# Token Application: https://alltick.co
# Replace "testtoken" in the URL below with your own token
# API addresses for forex, cryptocurrencies, and precious metals:
# https://quote.alltick.io/quote-b-ws-api
# Stock API address:
# https://quote.alltick.io/quote-stock-b-ws-api
Encode the following JSON and copy it to the "query" field of the HTTP query string
{"trace": "python_http_test1", "data": {"code": "700.HK", "kline_type": 1, "kline_timestamp_end": 0, "query_kline_num": 2, "adjust_type": 0}}
{"trace": "python_http_test2", "data": {"symbol_list": [{"code": "700.HK"}, {"code": "UNH.US"}]}}
{"trace": "python_http_test3", "data": {"symbol_list": [{"code": "700.HK"}, {"code": "UNH.US"}]}}
'''
test_url1 = 'https://quote.alltick.io/quote-stock-b-api/kline?token=testtoken&query=%7B%22trace%22%20%3A%20%22python_http_test1%22%2C%22data%22%20%3A%20%7B%22code%22%20%3A%20%22700.HK%22%2C%22kline_type%22%20%3A%201%2C%22kline_timestamp_end%22%20%3A%200%2C%22query_kline_num%22%20%3A%202%2C%22adjust_type%22%3A%200%7D%7D'
test_url2 = 'https://quote.alltick.io/quote-stock-b-api/depth-tick?token=testtoken&query=%7B%22trace%22%20%3A%20%22python_http_test2%22%2C%22data%22%20%3A%20%7B%22symbol_list%22%3A%20%5B%7B%22code%22%3A%20%22700.HK%22%7D%2C%7B%22code%22%3A%20%22UNH.US%22%7D%5D%7D%7D'
test_url3 = 'https://quote.alltick.io/quote-stock-b-api/trade-tick?token=testtoken&query=%7B%22trace%22%20%3A%20%22python_http_test3%22%2C%22data%22%20%3A%20%7B%22symbol_list%22%3A%20%5B%7B%22code%22%3A%20%22700.HK%22%7D%2C%7B%22code%22%3A%20%22UNH.US%22%7D%5D%7D%7D'

resp1 = requests.get(url=test_url1, headers=test_headers)
time.sleep(1)
resp2 = requests.get(url=test_url2, headers=test_headers)
time.sleep(1)
resp3 = requests.get(url=test_url3, headers=test_headers)

# Decoded text returned by the request
text1 = resp1.text
print(text1)

text2 = resp2.text
print(text2)

text3 = resp3.text
print(text3)

AllTick网站

官方网站:

English
https://alltick.co/