查詢訂單列表
接口信息
接口: GET /api/v1/orders
描述: 靈活查詢訂單列表,支持多種過濾條件、分頁和排序
鑑權: Authorization請求頭附加JWT令牌
查詢參數
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
| order_hash | string | 否 | 訂單哈希值(精確匹配) |
| principal | string | 否 | 接收者地址(精確匹配) |
| ticker | string | 否 | 股票代碼(精確匹配或模糊搜索) |
| ticker_like | boolean | 否 | 是否啟用模糊搜索,默認false |
| exchange | int | 否 | 交易所ID(精確匹配) |
| asset | string | 否 | 資產代幣地址(精確匹配) |
| is_buy | boolean | 否 | 是否為買單(精確匹配) |
| nonce | int | 否 | 防重放數字(精確匹配) |
| price_min | string | 否 | 最小價格 |
| price_max | string | 否 | 最大價格 |
| quantity_min | string | 否 | 最小數量 |
| quantity_max | string | 否 | 最大數量 |
| incentive_min | string | 否 | 最小激勵金額 |
| incentive_max | string | 否 | 最大激勵金額 |
| filled_quantity_min | string | 否 | 最小已成交數量 |
| filled_quantity_max | string | 否 | 最大已成交數量 |
| status | string | 否 | 訂單狀態,支持多個(逗號分隔,如"pending,filled") |
| deadline_after | int | 否 | 最早截止時間(Unix時間戳) |
| deadline_before | int | 否 | 最晚截止時間(Unix時間戳) |
| created_after | int | 否 | 最早創建時間(Unix時間戳) |
| created_before | int | 否 | 最晚創建時間(Unix時間戳) |
| sort_by | string | 否 | 排序字段(price, quantity, incentive, deadline, created_at),默認created_at |
| sort_order | string | 否 | 排序方向(asc, desc),默認desc |
| page | int | 否 | 頁碼,默認1 |
| page_size | int | 否 | 每頁數量,默認20,最大100 |
響應參數
| 字段 | 類型 | 說明 |
|---|---|---|
| total | int | 總記錄數 |
| page | int | 當前頁碼 |
| page_size | int | 每頁數量 |
| total_pages | int | 總頁數 |
| orders | array | 訂單列表 |
訂單對象字段
| 字段 | 類型 | 說明 |
|---|---|---|
| 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 | 訂單狀態 |
| filled_quantity | string | 已成交數量(wei單位) |
| notes | string | 備註(可選) |
| created_at | string | 創建時間(ISO 8601格式) |
| updated_at | string | 更新時間(ISO 8601格式) |
| fills | array | 成交明細列表(僅partially_filled和filled狀態訂單返回) |
成交明細對象字段
| 字段 | 類型 | 說明 |
|---|---|---|
| id | string | 成交記錄ID(UUID) |
| order_id | string | 訂單ID |
| order_hash | string | 訂單哈希值 |
| taker | string | Taker地址 |
| fill_quantity | string | 成交數量(wei單位) |
| fill_amount | string | 成交金額(wei單位) |
| fee_amount | string | 手續費金額(wei單位) |
| incentive_amount | string | 激勵金額(wei單位) |
| taker_incentive | string | Taker激勵(wei單位) |
| tx_hash | string | 交易哈希 |
| block_number | int | 區塊號 |
| status | string | 成交狀態 |
| reference_id | string | 參考ID(可選) |
| created_at | string | 創建時間(ISO 8601格式) |
請求示例
bash
# 基礎查詢
curl -X GET "/api/v1/orders?ticker=AAPL&page=1&page_size=20" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json"
# 多狀態查詢
curl -X GET "/api/v1/orders?status=pending,partially_filled" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json"
# 價格範圍查詢
curl -X GET "/api/v1/orders?price_min=100000000000000000000&price_max=200000000000000000000" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json"響應示例
json
{
"code": 0,
"data": {
"total": 3,
"page": 1,
"page_size": 20,
"total_pages": 1,
"orders": [
{
"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"
},
{
"id": "660e8400-e29b-41d4-a716-446655440001",
"maker": "0x1234567890123456789012345678901234567890",
"principal": "0x1234567890123456789012345678901234567890",
"is_buy": false,
"ticker": "TSLA",
"exchange": 0,
"asset": "0x09671802Cc9Bbf6402f2e7a07b220Aa7b43D8c91",
"price": "245000000000000000000",
"quantity": "5000000000000000000",
"incentive": "50000000000000000",
"deadline": 1735747200,
"nonce": 2,
"signature": "0x789012fedcba...",
"order_hash": "0x789012fedcba...",
"status": "locked",
"filled_quantity": "0",
"notes": null,
"created_at": "2025-01-17T05:30:00Z",
"updated_at": "2025-01-17T06:15:00Z"
},
{
"id": "770e8400-e29b-41d4-a716-446655440002",
"maker": "0x1234567890123456789012345678901234567890",
"principal": "0x1234567890123456789012345678901234567890",
"is_buy": true,
"ticker": "GOOGL",
"exchange": 0,
"asset": "0x09671802Cc9Bbf6402f2e7a07b220Aa7b43D8c91",
"price": "138500000000000000000",
"quantity": "20000000000000000000",
"incentive": "200000000000000000",
"deadline": 1735833600,
"nonce": 3,
"signature": "0xfedcba987654...",
"order_hash": "0xfedcba987654...",
"status": "filled",
"filled_quantity": "20000000000000000000",
"notes": null,
"created_at": "2025-01-16T10:00:00Z",
"updated_at": "2025-01-17T08:45:00Z",
"fills": [
{
"id": "880e8400-e29b-41d4-a716-446655440003",
"order_id": "770e8400-e29b-41d4-a716-446655440002",
"order_hash": "0xfedcba987654...",
"taker": "0x9876543210987654321098765432109876543210",
"fill_quantity": "20000000000000000000",
"fill_amount": "2770000000000000000000",
"fee_amount": "13850000000000000000",
"incentive_amount": "200000000000000000",
"taker_incentive": "200000000000000000",
"tx_hash": "0xabcdef123456789...",
"block_number": 12345678,
"status": "confirmed",
"reference_id": "Taker-1737105945abc",
"created_at": "2025-01-17T08:45:00Z"
}
]
}
]
}
}