跳到主要内容

查询订单

描述

查询单笔订单的当前状态。若订单不存在或属于其他用户,均返回 404——两种情况返回相同响应,调用方无法探测其他用户的订单是否存在。

HTTP 请求

GET /spot/orders/:id(JWT 或 API Key)

权重

0——订单接口不受按 IP 权重限制约束。

请求参数

名称类型必填描述
idSTRING(路径参数)待查询订单的 UUID。由新建订单的响应 id 字段返回。

响应示例

200 OK

{
"id": "9f2a1c4e-5b67-4d8a-bf93-2e1f4a6c8d10",
"symbol": "DFUSDT",
"side": "buy",
"type": "limit",
"tif": "gtc",
"price": "0.5000",
"quantity": "100",
"quote_quantity": null,
"filled_qty": "100",
"avg_fill_price": "0.4990",
"status": "filled",
"reject_reason": null,
"created_at": 1778400000,
"updated_at": 1778400090
}
字段说明
id服务器生成的订单 UUID。
status参见订单状态。终态:filled / canceled / rejected
filled_qty所有成交累计的基础资产成交数量。
avg_fill_price所有成交的成交量加权平均价格。若尚无成交则为 "0"
quote_quantity仅市价买单时有值(与原始请求一致);其他情况为 null
reject_reasonstatus=rejected 时不为 null;包含拒绝原因的错误码字符串。
created_at, updated_atUNIX

注意:新建订单不同,本接口的响应不包含 fills 数组。如需获取订单的逐笔成交记录,请使用账户成交记录

错误响应

HTTPerror触发条件
400invalid id:id 不是有效的 UUID。
404ORDER_NOT_FOUND订单不存在,或属于其他用户。
500DB_ERROR服务端故障。

完整列表:错误码

代码示例

cURL(JWT)

JWT="your_jwt_token"
ORDER_ID="9f2a1c4e-5b67-4d8a-bf93-2e1f4a6c8d10"

curl -s "https://api-sepolia.p99.world/api/v1/spot/orders/${ORDER_ID}" \
-H "Authorization: Bearer ${JWT}"

cURL(HMAC API Key)

API_KEY="your_api_key"
API_SECRET="your_api_secret"
ORDER_ID="9f2a1c4e-5b67-4d8a-bf93-2e1f4a6c8d10"
TIMESTAMP=$(date +%s%3N)
PAYLOAD="timestamp=${TIMESTAMP}"
SIGNATURE=$(echo -n "${PAYLOAD}" | openssl dgst -sha256 -hmac "${API_SECRET}" | awk '{print $2}')

curl -s \
-H "X-MBX-APIKEY: ${API_KEY}" \
"https://api-sepolia.p99.world/api/v1/spot/orders/${ORDER_ID}?timestamp=${TIMESTAMP}&signature=${SIGNATURE}"

Python

import time, hmac, hashlib, requests

API_KEY = "your_api_key"
API_SECRET = "your_api_secret"
BASE_URL = "https://api-sepolia.p99.world/api/v1"

def signed_get(path: str) -> dict:
ts = int(time.time() * 1000)
payload = f"timestamp={ts}"
sig = hmac.new(API_SECRET.encode(), payload.encode(), hashlib.sha256).hexdigest()
r = requests.get(
f"{BASE_URL}{path}?timestamp={ts}&signature={sig}",
headers={"X-MBX-APIKEY": API_KEY},
timeout=5,
)
r.raise_for_status()
return r.json()

order_id = "9f2a1c4e-5b67-4d8a-bf93-2e1f4a6c8d10"
order = signed_get(f"/spot/orders/{order_id}")
print(order["id"], order["status"], order["filled_qty"], "/", order["quantity"])

# Poll until terminal
import time as time_module
while order["status"] not in ("filled", "canceled", "rejected"):
time_module.sleep(1)
order = signed_get(f"/spot/orders/{order_id}")
print(f" status={order['status']} filled={order['filled_qty']}")