GET
/api/v1/klines
Get Historical K-line Data
Get historical K-line (candlestick) data for a specific trading pair, supporting multiple time intervals. API authentication required.
Request Parameters
Response Example
{
"code": 200,
"msg": "success",
"data": [
{
"timestamp": 1701234000,
"open": "45000.00",
"high": "45500.00",
"low": "44800.00",
"close": "45200.00",
"volume": "1234.56"
},
{
"timestamp": 1701237600,
"open": "45200.00",
"high": "45800.00",
"low": "45100.00",
"close": "45600.00",
"volume": "2345.67"
}
]
}
Code Example
// cURL示例(需要认证)
curl -X GET "https://ziario.com/api/v1/klines?symbol=BTCUSDT&interval=1h&limit=100" \
-H "X-API-Key: your_api_key" \
-H "X-Signature: your_signature" \
-H "X-Timestamp: 1701234567"
// PHP示例
$apiKey = "your_api_key";
$apiSecret = "your_api_secret";
$timestamp = time();
$params = [
"symbol" => "BTCUSDT",
,
"interval" => "1h",
"limit" => 100
];
ksort($params);
$queryString = http_build_query($params);
$signString = $queryString . "×tamp=" . $timestamp;
$signature = hash_hmac("sha256", $signString, $apiSecret);
$ch = curl_init("https://ziario.com/api/v1/klines?" . $queryString);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-API-Key: " . $apiKey,
"X-Signature: " . $signature,
"X-Timestamp: " . $timestamp
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
print_r($data);
// JavaScript示例
const apiKey = "your_api_key";
const apiSecret = "your_api_secret";
const timestamp = Math.floor(Date.now() / 1000);
const params = {
symbol: "BTCUSDT",
,
interval: "1h",
limit: 100
};
const sortedKeys = Object.keys(params).sort();
const queryString = sortedKeys.map(k => `${k}=${params[k]}`).join("&");
const signString = queryString + `×tamp=${timestamp}`;
const signature = CryptoJS.HmacSHA256(signString, apiSecret).toString();
fetch(`https://ziario.com/api/v1/klines?${queryString}`, {
headers: {
"X-API-Key": apiKey,
"X-Signature": signature,
"X-Timestamp": timestamp.toString()
}
})
.then(response => response.json())
.then(data => console.log(data));
// Python示例
import hmac
import hashlib
import time
import requests
api_key = "your_api_key"
api_secret = "your_api_secret"
timestamp = int(time.time())
params = {
"symbol": "BTCUSDT",
"exchange": "binance",
"interval": "1h",
"limit": 100
}
sorted_params = sorted(params.items())
query_string = "&".join([f"{k}={v}" for k, v in sorted_params])
sign_string = query_string + f"×tamp={timestamp}"
signature = hmac.new(
api_secret.encode(),
sign_string.encode(),
hashlib.sha256
).hexdigest()
headers = {
"X-API-Key": api_key,
"X-Signature": signature,
"X-Timestamp": str(timestamp)
}
response = requests.get("https://ziario.com/api/v1/klines", params=params, headers=headers)
print(response.json())