K-Line Data API
Get historical candlestick (K-line) data for stocks with multiple time intervals.
| Method | Endpoint | Description |
|---|
| GET | /v1/indicators/time_series | Historical K-line (OHLCV) time series |
| GET | /v1/market/quote | Real-time quote (bid/ask/last) |
| GET | /v1/market/history | Export-friendly historical data |
| POST | /v1/market/chart/batch | Batch generate static charts |
1. Time Series
Get historical candlestick (K-line) data for stocks with multiple time intervals.
Endpoint
| Method | Endpoint |
|---|
| GET | /v1/indicators/time_series |
Request Parameters
| Parameter | Type | Required | Default | Description |
|---|
symbol | string | ✅ | - | Stock code (e.g., 000001.SZ, SZSE:000001) |
interval | string | - | 1d | Time interval: 1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w |
start_date | string | - | - | Start date (YYYY-MM-DD) |
end_date | string | - | - | End date (YYYY-MM-DD) |
adjust | string | - | qfq | Adjustment: qfq (forward), hfq (backward), empty (none) |
outputsize | int | - | 5000 | Number of records to return |
Try It
Code Examples
Python
import requests
import pandas as pd
API_KEY = "your_api_key"
# Get Ping An Bank daily data
response = requests.get(
"https://tickerlab.org/v1/indicators/time_series",
params={
"symbol": "000001.SZ",
"interval": "1d",
"start_date": "2024-01-01",
"outputsize": 100
},
headers={"X-API-Key": API_KEY}
)
data = response.json()
# Convert to DataFrame
df = pd.DataFrame(data["values"])
df["datetime"] = pd.to_datetime(df["datetime"])
print(df.head())
JavaScript
const API_KEY = 'your_api_key';
async function getKLineData(symbol, interval = '1d', days = 100) {
const params = new URLSearchParams({
symbol,
interval,
outputsize: days
});
const response = await fetch(
`https://tickerlab.org/v1/indicators/time_series?${params}`,
{ headers: { 'X-API-Key': API_KEY } }
);
return response.json();
}
// Usage
const data = await getKLineData('000001.SZ', '1d', 30);
console.log(`Fetched ${data.values.length} records`);
cURL
curl -G "https://tickerlab.org/v1/indicators/time_series" \
-H "X-API-Key: your_api_key" \
-d "symbol=000001.SZ" \
-d "interval=1d" \
-d "start_date=2024-01-01" \
-d "outputsize=100"
Response Example
{
"meta": {
"symbol": "000001.SZ",
"interval": "1d",
"currency": "CNY",
"exchange_timezone": "Asia/Shanghai",
"exchange": "SZSE",
"type": "Common Stock"
},
"values": [
{
"datetime": "2024-01-15 00:00:00",
"open": "10.25",
"high": "10.35",
"low": "10.20",
"close": "10.30",
"volume": "12345678"
}
],
"status": "ok"
}
Field Descriptions
| Field | Description |
|---|
datetime | Timestamp |
open | Opening price |
high | High price |
low | Low price |
close | Closing price |
volume | Trading volume |
2. Real-time Quote
Get the latest market quote information.
Endpoint
| Method | Endpoint |
|---|
| GET | /v1/market/quote |
Parameters
| Parameter | Type | Required | Description |
|---|
symbol | string | ✅ | Stock/Crypto code (e.g. BTCUSDT, 000001.SZ) |
Try It
Code Examples
Python
import requests
API_KEY = "your_api_key"
# Get real-time quote for BTCUSDT
response = requests.get(
"https://tickerlab.org/v1/market/quote",
params={"symbol": "BTCUSDT"},
headers={"X-API-Key": API_KEY}
)
data = response.json()
print(f"Current Price: {data['price']}")
print(f"Change Percent: {data['change_percent']}%")
JavaScript
const API_KEY = 'your_api_key';
const response = await fetch(
"https://tickerlab.org/v1/market/quote?symbol=BTCUSDT",
{ headers: { "X-API-Key": API_KEY } }
);
const data = await response.json();
console.log(`Current Price: ${data.price}`);
cURL
curl -H "X-API-Key: your_key" "https://tickerlab.org/v1/market/quote?symbol=BTCUSDT"
Response Example
{
"symbol": "BTCUSDT",
"price": 42000.50,
"change": 120.50,
"change_percent": 0.28,
"volume": 1500.23,
"timestamp": "2024-03-20T10:00:00Z"
}
3. History Data Export
Get standardized OHLCV historical data list.
Endpoint
| Method | Endpoint |
|---|
| GET | /v1/export/history |
Parameters
| Parameter | Type | Required | Default | Description |
|---|
symbol | string | ✅ | - | Code |
start_date | string | ✅ | - | Start Date (YYYY-MM-DD) |
end_date | string | ✅ | - | End Date (YYYY-MM-DD) |
interval | string | - | 1d | Interval |
format | string | - | csv | Output format: csv or json |
Try It
Code Examples
Python
import requests
API_KEY = "your_api_key"
response = requests.get(
"https://tickerlab.org/v1/export/history",
params={
"symbol": "SZSE:000001",
"start_date": "2024-01-01",
"end_date": "2024-12-31",
"format": "csv"
},
headers={"X-API-Key": API_KEY}
)
# Save as CSV file
with open("data.csv", "wb") as f:
f.write(response.content)
JavaScript
const response = await fetch(
"https://tickerlab.org/v1/export/history?symbol=SZSE:000001&start_date=2024-01-01&end_date=2024-12-31&format=json",
{ headers: { "X-API-Key": "your_api_key" } }
);
const data = await response.json();
console.log(data.values.slice(0, 5));
cURL
curl -H "X-API-Key: your_key" \
"https://tickerlab.org/v1/export/history?symbol=SZSE:000001&start_date=2024-01-01&end_date=2024-12-31&format=csv" \
-o data.csv
4. Batch Chart Generation
Generate multiple K-line charts (PNG format) in a single request.
Endpoint
| Method | Endpoint |
|---|
| POST | /v1/market/chart/batch |
Request Body (JSON)
[
{
"symbol": "BTCUSDT",
"interval": "4h",
"studies": [{"name": "RSI"}]
},
{
"symbol": "000001.SZ",
"interval": "1d",
"studies": [{"name": "MACD"}, {"name": "VWAP"}]
}
]
Code Examples
Python
import requests
API_KEY = "your_api_key"
# Batch chart generation config
payload = [
{
"symbol": "BTCUSDT",
"interval": "4h",
"studies": [{"name": "RSI"}]
},
{
"symbol": "000001.SZ",
"interval": "1d",
"studies": [{"name": "MACD"}, {"name": "VWAP"}]
}
]
response = requests.post(
"https://tickerlab.org/v1/market/chart/batch",
json=payload,
headers={"X-API-Key": API_KEY}
)
results = response.json()
# Print generated chart URLs
for res in results["results"]:
print(f"Symbol: {res['symbol']}")
print(f"Chart URL: {res['data']['url']}")
print("-" * 30)
JavaScript
const API_KEY = 'your_api_key';
const payload = [
{ symbol: "BTCUSDT", interval: "4h", studies: [{ name: "RSI" }] },
{ symbol: "000001.SZ", interval: "1d", studies: [{ name: "MACD" }] }
];
const response = await fetch("https://tickerlab.org/v1/market/chart/batch", {
method: "POST",
headers: {
"X-API-Key": API_KEY,
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
});
const data = await response.json();
data.results.forEach(res => {
console.log(`${res.symbol}: ${res.data.url}`);
});
Response Example
{
"count": 2,
"results": [
{
"status": "ok",
"symbol": "BTCUSDT",
"data": {
"url": "https://tickerlab.org/static/charts/btc_rsi_4h.png",
"expires_at": "2024-03-20T11:00:00Z"
}
},
{
"status": "ok",
"symbol": "000001.SZ",
"data": {
"url": "https://tickerlab.org/static/charts/sz000001_macd_vwap_1d.png",
"expires_at": "2024-03-20T11:00:00Z"
}
}
]
}