01
Getting Started
1.1 What is this?
AllTick is a real-time financial market data service. You only need to call API to get the following data:
| data type | Popular understanding | Supported instruments |
|---|---|---|
| Latest trade price (Tick) | The price of the latest trade | All instruments |
| Order Book Depth (Order Book) | Buy 1~Buy N, Sell 1~Sell N queued orders | Some instruments (some CFD indices and market indices are not supported) |
| K-line (K-Line) | OHLCV of 1 minute/day/week/month etc. period | All instruments |
| Batch K-line (Batch-klien) | Query the latest two K-lines for multiple instruments in one request | All instruments |
| Basic stock information | Earnings per share, dividends, market capitalization, etc. | Stocks only |
| Trading suspension and resumption information | Which stocks have been suspended from trading and when will they resume trading? | SSE/NYSE/NASDAQ |
1.2 Three-step integration process
Step 1: Register and get Token (5 minutes)
Step 2: Understand Instrument Code (2 minutes)
Step 3: Run the first Hello World request (3 minutes)
Step 1: Get Token
- Fill in your email + password → click "Register" (pay attention to capitalization, special characters, and numbers)
- Automatically jump to Dashboard after successful registration → Find your Token in “API Keys”
- Start testing with the free tier, no fees required
Step 2: Understand instrument codes
Each instrument has a unique code, the rules are as follows:
| market | Code format | Example | Additional information |
|---|---|---|---|
| A shares (Shenzhen Stock Exchange) | 000000.SZ | 000627.SZ (Tianmao Group) | .SZ = Shenzhen |
| A shares (Shanghai Stock Exchange) | 000000.SH | 600416.SH (Xiangdian Electric Co., Ltd.) | .SH = Shanghai |
| Hong Kong stocks | 0000.HK | 700.HK (Tencent Holdings) | .HK = Hong Kong |
| US stocks | AAAA.US | AAPL.US (Apple) | .US = United States |
| Forex | XXXYYY | EURUSD, USDJPY | 6-digit letters, base currency + quote currency |
| cryptocurrency | XXXUSDT | BTCUSDT, ETHUSDT | Currency+USDT |
| Commodities/Precious Metals | English name | GOLD, SILVER, USOIL | — |
| CFD index | English code | See list for details | Not a broad market index, prices may vary slightly |
| Broad market index | English code | See list for details | — |
Step 3: Run the first request!
Javajava
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
import java.io.*;
import java.net.*;
public class HelloAllTick {
public static void main(String[] args) throws Exception {
String token = "YOUR_TOKEN_HERE";
String queryJson = "{\"trace\":\"hello123\",\"data\":{"
+ "\"code\":\"700.HK\","
+ "\"kline_type\":1," // 1 = 1-minute K-line
+ "\"kline_timestamp_end\":0,"
+ "\"query_kline_num\":2,"
+ "\"adjust_type\":0}}";
String urlStr = "https://quote.alltick.co/quote-stock-b-api/kline"
+ "?token=" + URLEncoder.encode(token, "UTF-8")
+ "&query=" + URLEncoder.encode(queryJson, "UTF-8");
HttpURLConnection conn = (HttpURLConnection) new URL(urlStr).openConnection();
conn.setRequestMethod("GET");
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(conn.getInputStream()))) {
String line;
StringBuilder response = new StringBuilder();
while ((line = reader.readLine()) != null) response.append(line);
System.out.println("Response:" + response);
}
}
}Pythonpython
# AllTick — Real-time Financial Market Data API
# Real-time Forex, Stocks, Crypto, Commodities and Indices market data
import requests
import json
TOKEN = "YOUR_TOKEN_HERE"
query_data = {
"trace": "hello123",
"data": {
"code": "700.HK",
"kline_type": 1, # 1 = 1-minute K-line
"kline_timestamp_end": 0, # 0 = start from the latest
"query_kline_num": 2, # request two K-lines
"adjust_type": 0
}
}
url = "https://quote.alltick.co/quote-stock-b-api/kline"
params = {
"token": TOKEN,
"query": json.dumps(query_data, separators=(',', ':'))
}
resp = requests.get(url, params=params, headers={"Content-Type": "application/json"})
print("Response:", resp.text)Gogo
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
token := "YOUR_TOKEN_HERE"
queryJSON := `{"trace":"hello123","data":{"code":"700.HK","kline_type":1,"kline_timestamp_end":0,"query_kline_num":2,"adjust_type":0}}`
fullURL := fmt.Sprintf("https://quote.alltick.co/quote-stock-b-api/kline?token=%s&query=%s",
token, url.QueryEscape(queryJSON))
resp, err := http.Get(fullURL)
if err != nil {
fmt.Println("Request failed:", err)
return
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println("Response:", string(body))
}C++ (requires libcurl installed)
CPPcpp
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
#include <iostream>
#include <string>
#include <curl/curl.h>
static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* out) {
size_t total = size * nmemb;
out->append((char*)contents, total);
return total;
}
int main() {
CURL* curl = curl_easy_init();
std::string token = "YOUR_TOKEN_HERE";
std::string queryJson = R"({"trace":"hello123","data":{"code":"700.HK","kline_type":1,"kline_timestamp_end":0,"query_kline_num":2,"adjust_type":0}})";
char* encoded = curl_easy_escape(curl, queryJson.c_str(), queryJson.length());
std::string url = "https://quote.alltick.co/quote-stock-b-api/kline?token="
+ token + "&query=" + std::string(encoded);
curl_free(encoded);
std::string response;
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
CURLcode res = curl_easy_perform(curl);
if (res == CURLE_OK)
std::cout << "Response:" << response << std::endl;
else
std::cerr << "Request failed: " << curl_easy_strerror(res) << std::endl;
curl_easy_cleanup(curl);
return 0;
}
// Compile:g++ -std=c++17 hello.cpp -lcurl -o hello1.3 Quick overview of general concepts
Request format (common to all HTTP endpoints)
Protocoltext
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
// GET request: URL-encode this JSON and place it in the ?query= parameter
{
"trace": "unique ID for each request (generate it yourself, such as a UUID, up to 64 characters)",
"data": { /* see each endpoint for its specific parameters */ }
}Response format (common to all endpoints)
Protocoltext
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
{
"ret": 200, // 200=success; other values are error codes (seePart 5)
"msg": "ok", // message
"trace": "returns the trace value from the request unchanged",
"data": { /* response data */ }
}HTTP vs WebSocket: How to choose?
| scene | What to use | reason |
|---|---|---|
| Poll K-lines periodically or query prices occasionally | HTTP REST | Simple, ready to use |
| Need to push prices and order book changes in real time | WebSocket | Push mode, low latency |
| Historical data initialization (first large-scale pull) | HTTP /kline | Up to 500 K-lines per request |
| Continuously updated with the latest data | HTTP /batch-kline | Batch efficient |
| High-frequency real-time quotes | WebSocket Subscribe | Automatically push after subscribing |
Endpoint URL quick reference
| data type | Stocks/Broad Market | Forex / Crypto / Commodities / CFD Index |
|---|---|---|
| HTTP base path | https://quote.alltick.co/quote-stock-b-api | https://quote.alltick.co/quote-b-api |
| WebSocket path | wss://quote.alltick.co/quote-stock-b-ws-api | wss://quote.alltick.co/quote-b-ws-api |
02
Product Code Quick Reference
Stocks
| market | Code format | Example |
|---|---|---|
| A shares (Shenzhen Stock Exchange) | Number.SZ | 000627.SZ (Tianmao Group) |
| A shares (Shanghai Stock Exchange) | Number.SH | 600416.SH (Xiangdian Electric Co., Ltd.) |
| Hong Kong stocks | Number.HK | 700.HK (Tencent Holdings) |
| US stocks | letters.US | AAPL.US (Apple) |
Forex & Cryptocurrencies & Commodities & Indices
| category | Code format | Example |
|---|---|---|
| Forex | XXXYYY | EURUSD, AUDJPY, GBPUSD |
| cryptocurrency | XXXUSDT | BTCUSDT, ETHUSDT, ADAUSDT |
| Commodities/Precious Metals | English name | GOLD, SILVER, USOIL, COPPER, NGAS |
| CFD index | English code | See the instrument list for details (not the market index, the price may be slightly different) |
| Broad market index | English code | See instrument list for details |
03
HTTP REST API Guide
3.1 Single-instrument K-line query → GET /kline
Request parameters
| Parameters | type | Required | illustrate |
|---|---|---|---|
| code | string | yes | instrument code |
| kline_type | int | yes | K-line type: 1=1 minute, 2=5 minutes, 3=15 minutes, 4=30 minutes, 5=hourly K-line, 6=2 hours (stocks are not supported), 7=4 hours (stocks are not supported), 8=daily K, 9=weekly K-line, 10=monthly K-line |
| kline_timestamp_end | int | yes | Starting point timestamp, 0 = starting from the latest; only foreign exchange precious metal encryption supports passing timestamps |
| query_kline_num | int | yes | Number of K-lines to return, maximum 500 |
| adjust_type | int | yes | Reright type: 0 = ex-rights (valid only for stocks, currently only 0 is supported) |
Response data
Protocoltext
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
{
"ret": 200, "msg": "ok",
"data": {
"code": "700.HK",
"kline_type": 1,
"kline_list": [
{
"timestamp": "1677829200",
"open_price": "136.421",
"close_price": "136.412",
"high_price": "136.422",
"low_price": "136.407",
"volume": "0",
"turnover": "0"
}
]
}
}Example: Query the latest 10 daily K-lines for Apple (AAPL.US)
Javajava
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
String token = "YOUR_TOKEN_HERE";
String queryJson = "{\"trace\":\"java_kline\",\"data\":{"
+ "\"code\":\"AAPL.US\",\"kline_type\":8," // 8 = daily K-line
+ "\"kline_timestamp_end\":0,\"query_kline_num\":10,\"adjust_type\":0}}";
String urlStr = "https://quote.alltick.co/quote-stock-b-api/kline"
+ "?token=" + URLEncoder.encode(token, "UTF-8")
+ "&query=" + URLEncoder.encode(queryJson, "UTF-8");
HttpURLConnection conn = (HttpURLConnection) new URL(urlStr).openConnection();
conn.setRequestMethod("GET");
try (BufferedReader r = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
StringBuilder sb = new StringBuilder(); String l;
while ((l = r.readLine()) != null) sb.append(l);
System.out.println(sb);
}Pythonpython
# AllTick — Real-time Financial Market Data API
# Real-time Forex, Stocks, Crypto, Commodities and Indices market data
import requests, json
TOKEN = "YOUR_TOKEN_HERE"
query = json.dumps({
"trace": "py_kline", "data": {
"code": "AAPL.US", "kline_type": 8,
"kline_timestamp_end": 0, "query_kline_num": 10, "adjust_type": 0
}
}, separators=(',', ':'))
resp = requests.get("https://quote.alltick.co/quote-stock-b-api/kline",
params={"token": TOKEN, "query": query})
print(resp.json())Gogo
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
q := map[string]interface{}{
"trace": "go_kline",
"data": map[string]interface{}{
"code": "AAPL.US", "kline_type": 8,
"kline_timestamp_end": 0, "query_kline_num": 10, "adjust_type": 0,
},
}
j, _ := json.Marshal(q)
full := fmt.Sprintf("https://quote.alltick.co/quote-stock-b-api/kline?token=%s&query=%s",
"YOUR_TOKEN_HERE", url.QueryEscape(string(j)))
resp, _ := http.Get(full)
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
fmt.Println(string(b))
}C++cpp
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
#include <iostream>
#include <string>
#include <curl/curl.h>
static size_t wcb(void* c, size_t s, size_t n, std::string* o) { o->append((char*)c, s*n); return s*n; }
int main() {
CURL* curl = curl_easy_init();
std::string q = R"({"trace":"cpp_kline","data":{"code":"AAPL.US","kline_type":8,"kline_timestamp_end":0,"query_kline_num":10,"adjust_type":0}})";
char* enc = curl_easy_escape(curl, q.c_str(), q.length());
std::string url = "https://quote.alltick.co/quote-stock-b-api/kline?token=YOUR_TOKEN_HERE&query=" + std::string(enc);
curl_free(enc);
std::string resp;
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, wcb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &resp);
curl_easy_perform(curl);
std::cout << resp << std::endl;
curl_easy_cleanup(curl);
}3.2 Batch K-line query → POST /batch-kline
/kline vs /batch-kline
/kline (GET) | /batch-kline (POST) | |
|---|---|---|
| Instruments per request | 1 | Multiple (different plans have different restrictions) |
| K-lines per instrument | Up to 500 | Maximum 2 |
| Parameter position | URL ?query= | Body(JSON) |
| use | Pulling historical data for the first time | Continuously updated with the latest data |
Maximum /batch-kline data groups by plan
| combo | Maximum number of groups (number of instruments × number of K-line types) |
|---|---|
| free | 5 sets |
| Base | 100 groups |
| advanced | 200 groups |
| Professional / All Hong Kong stocks / All A shares / All US stocks | 500 groups |
Request example
Protocoltext
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
// POST Body
{
"trace": "batch123",
"data": {
"data_list": [
{ "code": "700.HK", "kline_type": 1, "kline_timestamp_end": 0, "query_kline_num": 1, "adjust_type": 0 },
{ "code": "AAPL.US", "kline_type": 1, "kline_timestamp_end": 0, "query_kline_num": 1, "adjust_type": 0 }
]
}
}Javajava
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
String token = "YOUR_TOKEN_HERE";
String jsonBody = "{"
+ "\"trace\":\"java_batch\",\"data\":{\"data_list\":["
+ "{\"code\":\"700.HK\",\"kline_type\":1,\"kline_timestamp_end\":0,\"query_kline_num\":1,\"adjust_type\":0},"
+ "{\"code\":\"AAPL.US\",\"kline_type\":1,\"kline_timestamp_end\":0,\"query_kline_num\":1,\"adjust_type\":0}"
+ "]}}";
URL url = new URL("https://quote.alltick.co/quote-stock-b-api/batch-kline?token=" + token);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type", "application/json");
try (OutputStream os = conn.getOutputStream()) {
os.write(jsonBody.getBytes()); os.flush();
}
try (BufferedReader r = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
StringBuilder sb = new StringBuilder(); String l;
while ((l = r.readLine()) != null) sb.append(l);
System.out.println(sb);
}Pythonpython
# AllTick — Real-time Financial Market Data API
# Real-time Forex, Stocks, Crypto, Commodities and Indices market data
import requests, json
TOKEN = "YOUR_TOKEN_HERE"
body = {
"trace": "py_batch",
"data": {
"data_list": [
{"code": "700.HK", "kline_type": 1, "kline_timestamp_end": 0, "query_kline_num": 1, "adjust_type": 0},
{"code": "AAPL.US", "kline_type": 1, "kline_timestamp_end": 0, "query_kline_num": 1, "adjust_type": 0}
]
}
}
resp = requests.post(
f"https://quote.alltick.co/quote-stock-b-api/batch-kline?token={TOKEN}",
json=body
)
print(resp.json())Gogo
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
body := []byte(`{"trace":"go_batch","data":{"data_list":[{"code":"700.HK","kline_type":1,"kline_timestamp_end":0,"query_kline_num":1,"adjust_type":0},{"code":"AAPL.US","kline_type":1,"kline_timestamp_end":0,"query_kline_num":1,"adjust_type":0}]}}`)
resp, _ := http.Post(
"https://quote.alltick.co/quote-stock-b-api/batch-kline?token=YOUR_TOKEN_HERE",
"application/json", bytes.NewReader(body))
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
fmt.Println(string(b))
}C++cpp
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
#include <iostream>
#include <string>
#include <curl/curl.h>
static size_t wcb(void* c, size_t s, size_t n, std::string* o) { o->append((char*)c, s*n); return s*n; }
int main() {
CURL* curl = curl_easy_init();
std::string body = R"({"trace":"cpp_batch","data":{"data_list":[{"code":"700.HK","kline_type":1,"kline_timestamp_end":0,"query_kline_num":1,"adjust_type":0},{"code":"AAPL.US","kline_type":1,"kline_timestamp_end":0,"query_kline_num":1,"adjust_type":0}]}})";
struct curl_slist* headers = curl_slist_append(nullptr, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_URL, "https://quote.alltick.co/quote-stock-b-api/batch-kline?token=YOUR_TOKEN_HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, wcb);
std::string resp;
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &resp);
curl_easy_perform(curl);
std::cout << resp << std::endl;
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}3.3 Latest trade query → GET /trade-tick
Request parameters (query JSON)
Protocoltext
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
{
"trace": "tick123",
"data": {
"symbol_list": [
{"code": "700.HK"},
{"code": "AAPL.US"}
]
}
}Response data
Protocoltext
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
{
"ret": 200, "msg": "ok",
"data": {
"tick_list": [{
"code": "700.HK",
"seq": "30841439",
"tick_time": "1677831545217", // millisecond timestamp
"price": "136.302", // ← latest price
"volume": "0",
"turnover": "0",
"trade_direction": 0 // 0=default, 1=BUYbid, 2=SELLask
}]
}
}Javajava
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
String query = "{\"trace\":\"j_tick\",\"data\":{\"symbol_list\":[{\"code\":\"700.HK\"},{\"code\":\"AAPL.US\"}]}}";
String urlStr = "https://quote.alltick.co/quote-stock-b-api/trade-tick?token="
+ URLEncoder.encode(token, "UTF-8") + "&query=" + URLEncoder.encode(query, "UTF-8");
// GET request...Pythonpython
# AllTick — Real-time Financial Market Data API
# Real-time Forex, Stocks, Crypto, Commodities and Indices market data
import requests, json
TOKEN = "YOUR_TOKEN_HERE"
query = json.dumps({
"trace": "py_tick", "data": {
"symbol_list": [{"code": "700.HK"}, {"code": "AAPL.US"}]
}
}, separators=(',', ':'))
resp = requests.get("https://quote.alltick.co/quote-stock-b-api/trade-tick",
params={"token": TOKEN, "query": query})
print(resp.json())Gogo
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
q, _ := json.Marshal(map[string]interface{}{
"trace": "go_tick", "data": map[string]interface{}{
"symbol_list": []map[string]string{{"code": "700.HK"}, {"code": "AAPL.US"}},
}})
full := fmt.Sprintf("https://quote.alltick.co/quote-stock-b-api/trade-tick?token=%s&query=%s",
"YOUR_TOKEN_HERE", url.QueryEscape(string(q)))
resp, _ := http.Get(full)
// ...C++cpp
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
std::string q = R"({"trace":"cpp_tick","data":{"symbol_list":[{"code":"700.HK"},{"code":"AAPL.US"}]}})";
char* enc = curl_easy_escape(curl, q.c_str(), q.length());
std::string url = "https://quote.alltick.co/quote-stock-b-api/trade-tick?token=YOUR_TOKEN_HERE&query=" + std::string(enc);
// curl_easy_perform ...3.4 Order book query → GET /depth-tick
Order book depth by market
| market | Maximum number of gears | Special instructions |
|---|---|---|
| Forex / Precious Metals / Crude Oil / CFD Index | 1st gear | Quantity |
| cryptocurrency | 5th gear | Quantity |
| Hong Kong stocks | 10 gears | Quantity |
| US stocks | 1st gear | Quantity |
| Shanghai and Shenzhen A shares | 5th gear | Quantity |
Response example
Protocoltext
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
{
"ret": 200,
"data": {
"tick_list": [{
"code": "700.HK",
"bids": [{"price": "136.42", "volume": "100000"}],
"asks": [{"price": "136.43", "volume": "400000"}]
}]
}
}Javajava
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
String query = "{\"trace\":\"j_depth\",\"data\":{\"symbol_list\":[{\"code\":\"700.HK\"}]}}";
String urlStr = "https://quote.alltick.co/quote-stock-b-api/depth-tick?token="
+ URLEncoder.encode(token, "UTF-8") + "&query=" + URLEncoder.encode(query, "UTF-8");
// GET request...Pythonpython
# AllTick — Real-time Financial Market Data API
# Real-time Forex, Stocks, Crypto, Commodities and Indices market data
query = json.dumps({"trace": "py_depth", "data": {"symbol_list": [{"code": "700.HK"}]}}, separators=(',', ':'))
resp = requests.get("https://quote.alltick.co/quote-stock-b-api/depth-tick",
params={"token": TOKEN, "query": query})
print(resp.json())Gogo
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
q, _ := json.Marshal(map[string]interface{}{
"trace": "go_depth", "data": map[string]interface{}{
"symbol_list": []map[string]string{{"code": "700.HK"}},
}})
full := fmt.Sprintf("https://quote.alltick.co/quote-stock-b-api/depth-tick?token=%s&query=%s",
"YOUR_TOKEN_HERE", url.QueryEscape(string(q)))
// ...C++cpp
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
std::string q = R"({"trace":"cpp_depth","data":{"symbol_list":[{"code":"700.HK"}]}})";
char* enc = curl_easy_escape(curl, q.c_str(), q.length());
std::string url = "https://quote.alltick.co/quote-stock-b-api/depth-tick?token=YOUR_TOKEN_HERE&query=" + std::string(enc);
// ...3.5 Basic stock information → GET /static_info
Response key fields
| Field | meaning |
|---|---|
| name_cn / name_en / name_hk | Chinese/English/Traditional name |
| currency | Transaction currency |
| eps / eps_ttm | Earnings per share / Earnings per share (TTM) |
| bps | Net assets per share |
| dividend_yield | dividend yield |
| lot_size | Number of shares per lot |
| total_shares / circulating_shares | Total share capital / circulating share capital |
| exchange / board | Exchange/sector |
Javajava
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
String query = "{\"trace\":\"j_info\",\"data\":{\"symbol_list\":[{\"code\":\"700.HK\"}]}}";
String urlStr = "https://quote.alltick.co/quote-stock-b-api/static_info?token="
+ URLEncoder.encode(token, "UTF-8") + "&query=" + URLEncoder.encode(query, "UTF-8");
// GET...Pythonpython
# AllTick — Real-time Financial Market Data API
# Real-time Forex, Stocks, Crypto, Commodities and Indices market data
query = json.dumps({"trace":"py_info","data":{"symbol_list":[{"code":"700.HK"}]}}, separators=(',',':'))
resp = requests.get("https://quote.alltick.co/quote-stock-b-api/static_info",
params={"token": TOKEN, "query": query})
data = resp.json()
for stock in data["data"]["static_info_list"]:
print(f"{stock['name_cn']}: EPS={stock['eps']}, dividend yield={stock['dividend_yield']}")Gogo
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
q, _ := json.Marshal(map[string]interface{}{
"trace": "go_info", "data": map[string]interface{}{
"symbol_list": []map[string]string{{"code": "700.HK"}},
}})
full := fmt.Sprintf("https://quote.alltick.co/quote-stock-b-api/static_info?token=%s&query=%s",
"YOUR_TOKEN_HERE", url.QueryEscape(string(q)))
// ...C++cpp
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
std::string q = R"({"trace":"cpp_info","data":{"symbol_list":[{"code":"700.HK"}]}})";
char* enc = curl_easy_escape(curl, q.c_str(), q.length());
std::string url = "https://quote.alltick.co/quote-stock-b-api/static_info?token=YOUR_TOKEN_HERE&query=" + std::string(enc);
// ...3.6 Trading halt query → GET /api/suspension
Three endpoints
| exchange | URL | illustrate |
|---|---|---|
| Shanghai Stock Exchange SSE | https://quote.alltick.co/api/suspension/sse | Shanghai Stock Exchange |
| NYSE | https://quote.alltick.co/api/suspension/nyse | New York Stock Exchange |
| NASDAQ NASDAQ | https://quote.alltick.co/api/suspension/nasdaq | Nasdaq exchange |
Parameters
| Parameters | type | Required | illustrate |
|---|---|---|---|
| token | string | yes | YourToken |
| page | int | no | Page numbers (optional pagination) |
| size | int | no | Size per page (optional pagination) |
Response example (SSE)
JSONjson
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
{
"success": true,
"timestamp": "2024-01-15T10:30:00",
"totalCount": 125,
"data": [
{
"symbol": "600000",
"symbolName": "Shanghai Pudong Development Bank",
"haltReason": "trading halt for a material event",
"haltDate": "2024-01-15",
"haltTime": "09:30:00",
"haltPeriod": "halted for the full day",
"resumeDate": "2024-01-16",
"resumeTime": "09:30:00",
"publishDate": "2024-01-14 18:00:00"
}
]
}Javajava
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
String urlStr = "https://quote.alltick.co/api/suspension/sse?token="
+ URLEncoder.encode(token, "UTF-8") + "&page=1&size=10";
// GET...Pythonpython
# AllTick — Real-time Financial Market Data API
# Real-time Forex, Stocks, Crypto, Commodities and Indices market data
resp = requests.get("https://quote.alltick.co/api/suspension/sse",
params={"token": TOKEN, "page": 1, "size": 10})
print(resp.json())Gogo
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
resp, _ := http.Get("https://quote.alltick.co/api/suspension/sse?token=YOUR_TOKEN_HERE&page=1&size=10")
// ...C++cpp
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
curl_easy_setopt(curl, CURLOPT_URL, "https://quote.alltick.co/api/suspension/sse?token=YOUR_TOKEN_HERE&page=1&size=10");
// ...04
WebSocket API Guide
WebSocket connection address
| data type | address |
|---|---|
| Stocks/Broad Market | wss://quote.alltick.co/quote-stock-b-ws-api?token=YOUR_TOKEN_HERE |
| Forex / Crypto / Commodities / CFD Index | wss://quote.alltick.co/quote-b-ws-api?token=YOUR_TOKEN_HERE |
Four protocol IDs
| You send (cmd_id) | Server response (cmd_id) | Server push (cmd_id) | use |
|---|---|---|---|
| 22000 | 22001 | — | heartbeat |
| 22002 | 22003 | 22999 | Subscribe to Order book |
| 22004 | 22005 | 22998 | Subscribe to trades |
| 22006 | 22007 | — | Unsubscribe |
Common message format
Protocoltext
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
// all requests
{
"cmd_id": 22002, // protocol ID
"seq_id": 123, // sequence ID (defined by the client)
"trace": "uuid-xxxx", // trace ID (up to 64 characters)
"data": { /* ... */ }
}
// all responses and pushes
{
"ret": 200,
"msg": "ok",
"cmd_id": 22003,
"seq_id": 123,
"trace": "uuid-xxxx",
"data": { /* ... */ }
}Key considerations
- Subscription override rules: Each subscription request will overwrite the previous one. To append code all must be resent.
- 10-second heartbeat: After successful subscription, a heartbeat will be sent every 10 seconds. If there is no heartbeat for 30 seconds, it will be disconnected.
- Request interval: The interval between two requests in the same WebSocket is at least 1 second; the interval between multiple WebSocket is at least 3 seconds.
- Automatic reconnection: It is strongly recommended to implement automatic reconnection after disconnection + automatic resubscription after reconnection.
- K-line does not support push: WebSocket cannot subscribe to K-line, and K-line can only be obtained through HTTP.
4.1 Heartbeat → cmd_id 22000/22001
Protocoltext
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
// send(22000)
{"cmd_id":22000, "seq_id":123, "trace":"hb", "data":{}}
// Response(22001)
{"ret":200, "msg":"ok", "cmd_id":22001, "seq_id":123, "trace":"hb", "data":{}}Java (javax.websocket / Tyrus)
JAVAjava
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
if (session != null && session.isOpen()) {
session.getBasicRemote().sendText(
"{\"cmd_id\":22000,\"seq_id\":123,\"trace\":\"hb\",\"data\":{}}");
}
}
}, 0, 10_000);Python (websocket-client)
PYTHONpython
# AllTick — Real-time Financial Market Data API
# Real-time Forex, Stocks, Crypto, Commodities and Indices market data
import websocket, json, time, threading
ws = websocket.WebSocketApp("wss://quote.alltick.co/quote-stock-b-ws-api?token=YOUR_TOKEN_HERE")
def on_open(ws):
def heartbeat():
while ws.sock and ws.sock.connected:
time.sleep(10)
ws.send(json.dumps({"cmd_id":22000,"seq_id":123,"trace":"hb","data":{}}))
threading.Thread(target=heartbeat, daemon=True).start()
ws.on_open = on_open
ws.run_forever()Go (gorilla/websocket)
GOgo
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
import (
"github.com/gorilla/websocket"
"time"
)
conn, _, _ := websocket.DefaultDialer.Dial("wss://quote.alltick.co/quote-stock-b-ws-api?token=YOUR_TOKEN_HERE", nil)
defer conn.Close()
go func() {
ticker := time.NewTicker(10 * time.Second)
for range ticker.C {
msg := `{"cmd_id":22000,"seq_id":123,"trace":"hb","data":{}}`
conn.WriteMessage(websocket.TextMessage, []byte(msg))
}
}()C++ (IXWebSocket)
CPPcpp
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
#include <ixwebsocket/IXWebSocket.h>
#include <thread>
ix::WebSocket ws;
ws.setUrl("wss://quote.alltick.co/quote-stock-b-ws-api?token=YOUR_TOKEN_HERE");
ws.setOnMessageCallback([](const ix::WebSocketMessagePtr& msg) {
if (msg->type == ix::WebSocketMessageType::Message)
std::cout << "received: " << msg->str << std::endl;
});
ws.start();
while (true) {
std::this_thread::sleep_for(std::chrono::seconds(10));
ws.send(R"({"cmd_id":22000,"seq_id":123,"trace":"hb","data":{}})");
}4.2 Trade subscription → cmd_id 22004/22005 → Push 22998
Subscription message
JSONjson
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
{
"cmd_id": 22004,
"seq_id": 123,
"trace": "sub_trade",
"data": {
"symbol_list": [
{"code": "700.HK"},
{"code": "AAPL.US"}
]
}
}Push message (cmd_id: 22998)
JSONjson
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
{
"cmd_id": 22998,
"data": {
"code": "700.HK",
"seq": 1605509068000001,
"tick_time": 1605509068,
"price": "651.12",
"volume": "300",
"turnover": "12345.6",
"trade_direction": 1
}
}Javajava
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
String subMsg = "{"
+ "\"cmd_id\":22004,\"seq_id\":123,\"trace\":\"trade_sub\","
+ "\"data\":{\"symbol_list\":[{\"code\":\"700.HK\"},{\"code\":\"AAPL.US\"}]}}";
session.getBasicRemote().sendText(subMsg);Pythonpython
# AllTick — Real-time Financial Market Data API
# Real-time Forex, Stocks, Crypto, Commodities and Indices market data
def on_open(ws):
sub = {
"cmd_id": 22004, "seq_id": 123, "trace": "trade_sub",
"data": {"symbol_list": [{"code": "700.HK"}, {"code": "AAPL.US"}]}
}
ws.send(json.dumps(sub))Gogo
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
sub := `{"cmd_id":22004,"seq_id":123,"trace":"trade_sub","data":{"symbol_list":[{"code":"700.HK"},{"code":"AAPL.US"}]}}`
conn.WriteMessage(websocket.TextMessage, []byte(sub))C++cpp
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
ws.send(R"({"cmd_id":22004,"seq_id":123,"trace":"trade_sub","data":{"symbol_list":[{"code":"700.HK"},{"code":"AAPL.US"}]}})");4.3 Order book subscription → cmd_id 22002/22003 → Push 22999
Subscription message (includes the depth_level field)
JSONjson
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
{
"cmd_id": 22002,
"seq_id": 123,
"trace": "sub_depth",
"data": {
"symbol_list": [
{"code": "700.HK", "depth_level": 5},
{"code": "AAPL.US", "depth_level": 1}
]
}
}Push message (cmd_id: 22999)
JSONjson
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
{
"cmd_id": 22999,
"data": {
"code": "700.HK",
"seq": 1605509068000001,
"tick_time": 1605509068,
"bids": [{"price": "9.12", "volume": "1000"}],
"asks": [{"price": "9.13", "volume": "500"}]
}
}Javajava
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
String subMsg = "{"
+ "\"cmd_id\":22002,\"seq_id\":123,\"trace\":\"depth_sub\","
+ "\"data\":{\"symbol_list\":["
+ "{\"code\":\"700.HK\",\"depth_level\":5},"
+ "{\"code\":\"AAPL.US\",\"depth_level\":1}"
+ "]}}";
session.getBasicRemote().sendText(subMsg);Pythonpython
# AllTick — Real-time Financial Market Data API
# Real-time Forex, Stocks, Crypto, Commodities and Indices market data
def on_open(ws):
sub = {
"cmd_id": 22002, "seq_id": 123, "trace": "depth_sub",
"data": {"symbol_list": [
{"code": "700.HK", "depth_level": 5},
{"code": "AAPL.US", "depth_level": 1}
]}
}
ws.send(json.dumps(sub))Gogo
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
sub := `{"cmd_id":22002,"seq_id":123,"trace":"depth_sub","data":{"symbol_list":[{"code":"700.HK","depth_level":5},{"code":"AAPL.US","depth_level":1}]}}`
conn.WriteMessage(websocket.TextMessage, []byte(sub))C++cpp
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
ws.send(R"({"cmd_id":22002,"seq_id":123,"trace":"depth_sub","data":{"symbol_list":[{"code":"700.HK","depth_level":5},{"code":"AAPL.US","depth_level":1}]}})");4.4 Unsubscribe → cmd_id 22006/22007
Protocoltext
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
// send(22006)
{
"cmd_id": 22006, "seq_id": 123, "trace": "cancel",
"data": { "cancel_type": 0 } // 0=cancel all, 1=cancel order book only, 2=cancel trades only
}Javajava
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
session.getBasicRemote().sendText(
"{\"cmd_id\":22006,\"seq_id\":123,\"trace\":\"cancel\",\"data\":{\"cancel_type\":0}}");Pythonpython
# AllTick — Real-time Financial Market Data API
# Real-time Forex, Stocks, Crypto, Commodities and Indices market data
ws.send(json.dumps({"cmd_id":22006,"seq_id":123,"trace":"cancel","data":{"cancel_type":0}}))Gogo
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
conn.WriteMessage(websocket.TextMessage, []byte(`{"cmd_id":22006,"seq_id":123,"trace":"cancel","data":{"cancel_type":0}}`))C++cpp
// AllTick — Real-time Financial Market Data API
// Real-time Forex, Stocks, Crypto, Commodities and Indices market data
ws.send(R"({"cmd_id":22006,"seq_id":123,"trace":"cancel","data":{"cancel_type":0}})");05
Error Code Quick Reference
| error code | error message | Meaning & troubleshooting suggestions |
|---|---|---|
| 200 | ok | success |
| 400 | request header param invalid | JSON First layer parameter error → Check whether the trace and data fields exist and have a complete structure |
| 400 | request data param invalid | Data field content is wrong → Check parameters against API documentation |
| 401 | token invalid | Token is invalid → Check whether the format is correct and whether it has expired |
| 402 | query invalid | GET parameter error → Check URL encoding and special character escaping |
| 429 | rate limit | Request overclocking → lower frequency or upgrade plan |
| 600 | code invalid | The instrument code is invalid → Check whether the URL path is correct (stock path ≠ foreign exchange path) and whether the case of code is consistent with the list |
| 601 | body empty | POST request body is empty → check whether the body is missing from APIs such as /batch-kline |
| 603 | token level not enough | Exceeding the plan limit → Reduce the number of instruments to /K and the number of lines, or upgrade the plan |
| 604 | code unauthorized | Token does not have permission to access this code → Contact customer service |
| 605 | too many requests | HTTP API frequency exceeds the limit → optimize frequency or upgrade |
| 606 | too many requests…connection will be closed | WebSocket request rate exceeds the limit → will be disconnected, check the number of connections and request interval |
06
Rate and Limit Quick Reference
HTTP endpoint rate limits by plan
| interface | free | Base | advanced | Professional / All Hong Kong stocks / All A shares / All US stocks |
|---|---|---|---|---|
| /kline | 1 time every 10 seconds | 1 time per second | 10 times per second | 20 times per second |
| /batch-kline | 1 time every 10 seconds | 1 time every 3 seconds | 1 time every 2 seconds | 1 time per second |
| /depth-tick | 1 time every 10 seconds | 1 time per second | 10 times per second | 20 times per second |
| /trade-tick | 1 time every 10 seconds | 1 time per second | 10 times per second | 20 times per second |
| /static_info | 1 time every 10 seconds | 1 time per second | 10 times per second | 20 times per second |
| Total of all APIs (per minute) | 10 times | 60 times | 600 times | 1200 times |
| Daily total request cap | 1,000 | 86,400 | 864,000 | 1,728,000 |
Maximum codes per HTTP request by plan
| interface | free | Basic+ | Remark |
|---|---|---|---|
| /trade-tick | 5 | Recommended ≤50 codes | GET URL length limit |
| /depth-tick | 5 | Recommended ≤50 codes | It is recommended to use WebSocket |
| /static_info | 5 | Recommended ≤50 codes | — |
| /batch-kline | 5 sets | 100~500 groups | 1 group = 1 instrument + 1K-line type |
WebSocket restrictions
| Restrictions | free | Base | advanced | Professional/All Hong Kong stocks/All A shares/All US stocks |
|---|---|---|---|---|
| Number of connections | 1 | 1 | 3 | 10 |
| Trade subscription codes | 5 | 100 | 200 | 3000 |
| Order book subscription codes | 5 | 100 | 200 | 3000 |
| heartbeat interval | 10 seconds | 10 seconds | 10 seconds | 10 seconds |
| Request interval | ≥1 second | ≥1 second | ≥1 second | ≥1 second |
| Multiple connection intervals | ≥3 seconds | ≥3 seconds | ≥3 seconds | ≥3 seconds |
07
Customer FAQ
General integration
Q1: Is the free plan enough?
Q2: How do I know whether an instrument is supported?
Q3: How do I troubleshoot error 600 “code invalid”?
Q4: How do I obtain a Token?
K-line questions
Q5: Can WebSocket push the K-line?
Q6: How do I retrieve and update K-lines efficiently?
Q7: Why does the stock not support 2-hour and 4-hour K-line?
Price and percentage change
Q8: How do I calculate percentage change?
- Daily percentage change:
(today's daily K-line close_price - previous day's daily K-line close_price) / previous day's daily K-line close_price × 100% - 24-hour percentage change: Subscribe to trades over WebSocket, retain the price from 24 hours earlier, and use
(latest price - price 24 hours ago) / price 24 hours ago × 100%
Q9: What does close_price represent during trading?
- During the trading period,
close_priceof the latest K-line = the latest trade price - During the market closure,
close_priceof the latest K-line = the closing price of the day
Order book and price limits
Q10: How do I identify limit-up and limit-down?
- High limit: bids has data, and the price and volume of asks are all 0
- Limit-down:
askscontains data while allbidsprices and volumes are 0
Q11: How do I determine whether a stock is delisted?
Q12: Why do some instruments have fewer order book levels than the documented maximum?
WebSocket related
Q13: How do I add another code to a subscription?
Q14: What should I do if the connection keeps disconnecting?
Q15: Can stocks and forex/crypto share one WebSocket connection?
Trading Hours & Holidays
Q16: Where can I find trading hours and market closures?
- Chinese channel: https://t.me/alltick_cn
- English channel: https://t.me/alltick_en
Q17: What is the difference between CFD index and market index?
Trading halts and new listings
Q18: How do I query trading halts?
Q19: How do I know when a new stock is listed?
Technical details
Q20: What is the trace field used for?
Q21: Must the GET query parameter be URL-encoded?
Q22: Can multiple endpoints be requested concurrently?
Contact and support
| channel | address |
|---|---|
| Official website | https://alltick.co |
| Alternate official website | https://alltick.io |
| support@alltick.co | |
| Telegram Chinese channel | https://t.me/alltick_cn |
| Telegram English Channel | https://t.me/alltick_en |
| GitHub | github.com/AllTick-Official |