接入教程
1. 访问Walltime官网注册账户并获取API密钥
2. 查阅API文档了解可用端点和参数
3. 使用HTTP GET请求调用市场数据接口
4. 解析返回的JSON数据并集成到您的应用中
5. 根据需求设置请求频率和数据缓存
Python:获取实时市场数据
python
import requests
url = 'https://api.example.com/v1/market/ticker'
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
params = {'symbol': 'BTC/USDT'}
response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:
data = response.json()
print('Market Data:', data)
else:
print('Error:', response.status_code, response.text)
PHP:查询市场深度
php
<?php
$url = 'https://api.example.com/v1/market/depth';
$params = ['symbol' => 'ETH/USDT', 'limit' => 10];
$query = http_build_query($params);
$fullUrl = $url . '?' . $query;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fullUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response === false) {
echo 'Curl error: ' . curl_error($ch);
} else {
$data = json_decode($response, true);
print_r($data);
}
curl_close($ch);
?>
JavaScript:获取价格波动历史
javascript
const url = 'https://api.example.com/v1/market/history';
const params = new URLSearchParams({
symbol: 'SOL/USDT',
interval: '1h',
limit: 24
});
fetch(`${url}?${params}`, {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
})
.then(response => {
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
return response.json();
})
.then(data => console.log('Price History:', data))
.catch(error => console.error('Fetch error:', error));
常见问题
如何获取API密钥?
请访问Walltime官方网站(https://walltime.info/api.html)注册账户,然后在开发者控制台生成您的API密钥。
API请求频率有限制吗?
是的,免费套餐每分钟最多允许60次请求。如需更高限制,请升级到付费计划。
支持哪些交易对?
Walltime API支持主流加密货币交易对,如BTC/USDT、ETH/USDT等。完整列表请参考API文档的市场端点。
Aitishiku.com