發現新訂單
接口信息
接口: GET /api/v1/orders/available
描述: 獲取所有可用的待處理訂單列表,作為WebSocket訂單推送的備用方式
鑑權: API Key憑據認證
查詢參數
無
響應參數
返回訂單數組,每個訂單包含以下字段:
| 字段 | 類型 | 說明 |
|---|---|---|
| id | string | 訂單ID(UUID) |
| maker | string | 訂單創建者地址 |
| principal | string | 接收者地址 |
| is_buy | boolean | 是否為買單 |
| ticker | string | 股票代碼 |
| exchange | int | 交易所ID |
| asset | string | 資產代幣地址 |
| price | string | 價格(wei單位) |
| quantity | string | 數量(wei單位) |
| incentive | string | 激勵金額(wei單位) |
| deadline | int | 截止時間(Unix時間戳) |
| nonce | int | 防重放數字 |
| signature | string | 訂單簽名 |
| order_hash | string | 訂單哈希值 |
| status | string | 訂單狀態(固定為"pending") |
| filled_quantity | string | 已成交數量(wei單位) |
| notes | string | 備註(可選) |
| created_at | string | 創建時間(ISO 8601格式) |
| updated_at | string | 更新時間(ISO 8601格式) |
請求示例
bash
curl -X GET "/api/v1/orders/available" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json"響應示例
json
{
"code": 0,
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"maker": "0x1234567890123456789012345678901234567890",
"principal": "0x1234567890123456789012345678901234567890",
"is_buy": true,
"ticker": "AAPL",
"exchange": 0,
"asset": "0x09671802Cc9Bbf6402f2e7a07b220Aa7b43D8c91",
"price": "150250000000000000000",
"quantity": "10000000000000000000",
"incentive": "100000000000000000",
"deadline": 1735660800,
"nonce": 1,
"signature": "0xabcdef123456...",
"order_hash": "0x123456abcdef...",
"status": "pending",
"filled_quantity": "0",
"notes": null,
"created_at": "2025-01-17T03:00:24Z",
"updated_at": "2025-01-17T03:00:24Z"
}
]
}注意事項
- 此接口返回所有pending狀態的訂單
- 建議優先使用WebSocket接收訂單推送,此接口作為備用輪詢方式
- 輪詢間隔建議不少於5秒,避免對服務器造成過大壓力
- 返回的訂單列表可能較大,建議根據需要進行過濾