API Reference
接口文档
统一的行情数据接口,覆盖加密货币、外汇、期货等市场。注册后 5 分钟内完成集成。
快速开始
注册后自动绑定试用套餐并生成 Access Key,按以下三步完成首次集成。
鉴权方式
行情接口(/v1/*)和 WebSocket 均使用 API Key 鉴权,通过请求头传入:
x-api-key: wk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
WebSocket 也支持 URL 参数传入:
wss://api.wktick.com/ws/quotes?apiKey=YOUR_ACCESS_KEY
每个账号只保留一个 Access Key。Key 泄漏后请在控制台立即重置,旧 Key 即刻失效。
查询产品列表
GET
/v1/products返回所有可用产品。可通过 marketType 过滤市场类型。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
marketType | string | 否 | STOCK / FUTURES / INDEX / FOREX / CRYPTO |
请求示例
GET /v1/products?marketType=CRYPTO x-api-key: YOUR_ACCESS_KEY
响应示例
{
"products": [
{
"symbol": "BTCUSDT",
"name": "BTC/USDT",
"marketType": "CRYPTO",
"exchange": "Huobi",
"dataSource": "huobi",
"status": "ACTIVE"
}
]
}查询实时报价
GET
/v1/quotes/:symbol返回指定产品的最新报价。优先从 Redis 缓存返回(延迟 <10ms),缓存命中时响应含 "source":"redis"。
路径参数
| 参数 | 说明 |
|---|---|
symbol | 产品代码,大小写不敏感,例如 BTCUSDT、EURUSD、XAUUSD |
请求示例
GET /v1/quotes/BTCUSDT x-api-key: YOUR_ACCESS_KEY
响应示例
{
"quote": {
"type": "quote",
"symbol": "BTCUSDT",
"price": "64218.23",
"open": "63900.00",
"high": "65000.00",
"low": "63500.00",
"volume": "1234.567890",
"sourceTime": "2026-06-29T10:00:00.000Z",
"receivedAt": "2026-06-29T10:00:00.050Z",
"dataSource": "huobi"
},
"source": "redis"
}查询 K 线数据
GET
/v1/klines/:symbol返回历史 K 线数据。支持多个时间周期,高周期 K 线由 1 分钟数据聚合而来。
请求参数
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
interval | string | 1m | 时间周期:1m / 5m / 15m / 30m / 1h / 4h / 1d / 1w |
limit | integer | 200 | 返回条数,最大 1000 |
请求示例
GET /v1/klines/BTCUSDT?interval=1h&limit=100 x-api-key: YOUR_ACCESS_KEY
响应示例
{
"symbol": "BTCUSDT",
"interval": "1h",
"klines": [
{
"openTime": "2026-06-29T09:00:00.000Z",
"open": 63900.00,
"high": 65000.00,
"low": 63500.00,
"close": 64218.23,
"volume": 7842.123456
}
]
}WebSocket 建立连接
WS
/ws/quotes连接成功后服务器立即推送 welcome 消息,包含连接 ID 和当前套餐限制。
连接示例
const ws = new WebSocket(
"wss://api.wktick.com/ws/quotes?apiKey=YOUR_ACCESS_KEY"
);
ws.onopen = () => console.log("connected");
ws.onmessage = (event) => {
const msg = JSON.parse(event.data);
console.log(msg.type, msg);
};Welcome 消息
{
"type": "welcome",
"connectionId": "a1b2c3d4-...",
"limits": {
"websocketConnectionLimit": 3,
"websocketSymbolLimit": 100
}
}WebSocket 订阅行情
连接建立后发送 JSON 消息订阅或取消订阅产品。单次可传多个 symbol。
订阅
ws.send(JSON.stringify({
"action": "subscribe",
"symbols": ["BTCUSDT", "EURUSD", "XAUUSD"]
}));
// 服务器确认
{ "type": "subscribed", "symbols": ["BTCUSDT", "EURUSD", "XAUUSD"] }
// 实时推送格式
{
"type": "quote",
"data": {
"symbol": "BTCUSDT",
"price": "64218.23",
"high": "65000.00",
"low": "63500.00",
"volume": "1234.56",
"sourceTime": "2026-06-29T10:00:05.000Z"
}
}取消订阅
ws.send(JSON.stringify({
"action": "unsubscribe",
"symbols": ["BTCUSDT"]
}));WebSocket 心跳保活
服务器在 60 秒内未收到任何消息将主动断开连接。建议每 30 秒发送一次 ping:
setInterval(() => {
if (ws.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify({ "action": "ping" }));
}
}, 30_000);
// 服务器回应
{ "type": "pong", "timestamp": "2026-06-29T10:00:30.000Z" }频率限制
每个套餐有独立的 HTTP 每分钟查询限制。超限时返回 429,响应头含 RateLimit-* 字段。
| 套餐 | HTTP/分钟 | WS 连接数 | WS 订阅总数 |
|---|---|---|---|
| Free Trial | 30 | 1 | 20 |
| Standard | 120 | 3 | 100 |
| Enterprise | 按需 | 专属 | 2000+ |
错误码参考
| HTTP | error 字段 | 说明 |
|---|---|---|
| 400 | validation_error | 请求参数格式错误 |
| 401 | missing_api_key | 未传入 x-api-key |
| 401 | invalid_api_key | Key 不存在或已禁用 |
| 401 | missing_token | 未传入 Bearer Token |
| 403 | ip_not_allowed | 当前 IP 不在白名单 |
| 404 | quote_not_found | 暂无该产品的行情数据 |
| 429 | rate_limited | 超过套餐 HTTP 查询频率 |
| 500 | internal_server_error | 服务器内部错误 |
错误响应格式
{
"error": "invalid_api_key",
"message": "API Key 不存在或已禁用。"
}在线调试
交互式 Demo
直接在页面内填写 API Key,向本地(或任意)API 服务发起真实请求,无需 curl / Postman。