Query orders (get_orders)
About 573 words
Queries orders by trace identifier, order number, or numeric order identifier. The response is an array of orders — querying by trace_id may return several.
- Permission:
order.read - Method:
GET - Idempotency: read-only
v1 draft
This page is part of the draft v1 integration contract; details may change along with the integration checklist, so rely on the official checklist published in the portal.
正在加载交互式结构…
Query conditions
trace_id, order_no, and order_id are mutually exclusive: pass one of the three. Precedence is trace_id > order_no > order_id:
| Condition | Semantics |
|---|---|
trace_id | Returns every order tagged with that trace_id; may be multiple |
order_no | Looks up a single order exactly |
order_id | Looks up a single order exactly |
When several are passed, only the one with the highest precedence takes effect; the rest are ignored.
Request example
Query by trace identifier (may return multiple orders):
GET /dist/api/v1/get_orders?trace_id=trace-7f3a9c&with_delivers=true HTTP/1.1
Host: api.xstock.example
X-Xstock-Api-Key: xs_live_xxxxxxxx
X-Xstock-Timestamp: 1795000000
X-Xstock-Signature: 9f2c...Query a single order exactly by order number:
GET /dist/api/v1/get_orders?order_no=XS20261124000123 HTTP/1.1Response example
{
"id": "shop-a-20261127-get-001",
"cmd": "get_orders",
"code": 0,
"msg": "",
"data": [
{
"order_id": 9001,
"order_no": "XS20261124000123",
"status": "delivered",
"trace_id": "trace-7f3a9c",
"dstm_order_ref": "202611240001",
"accept_state": "accepted",
"fulfill_state": "full",
"fund_state": "captured",
"ticket_state": "none",
"total": { "amt": "19.00", "ccy": "CNY" },
"created_at": "2026-11-24T13:05:21Z",
"fulfilled_at": "2026-11-24T13:05:48Z",
"cancelled_at": null,
"lines": [
{
"line_no": 1,
"sku_id": 1001,
"sku_guid": "5d8f2a6c9e1b4d3f8a7c0e2b5d9f1a3c",
"qty": 2,
"fulfilled_qty": 2,
"unit_price": { "amt": "9.50", "ccy": "CNY" }
}
],
"delivers": [
{
"line_no": 1,
"sku_id": 1001,
"sku_guid": "5d8f2a6c9e1b4d3f8a7c0e2b5d9f1a3c",
"artifact_id": "art_01",
"kind": "acct_bundle",
"logical_unit_cnt": 1,
"content": {
"username": "demo_user_01",
"password": "demo_pass_01"
}
}
]
}
],
"stamp": 1795000001
}data is an array, even when exactly one order matches; no match returns an empty array rather than a 404.
Order status
| Field | Values | Meaning |
|---|---|---|
accept_state | received / accepted / rejected | Acceptance state |
fulfill_state | none / full | Whether the order has been fulfilled in full |
fund_state | held / captured / released / refunded | Fund state |
ticket_state | none / open / resolving / resolved | After-sales ticket state |
status | See the table below | Aggregate status |
status | Meaning |
|---|---|
pending_payment | Awaiting payment (insufficient balance or no hold yet) |
paid | Accepted, funds held |
fulfilling | Being fulfilled |
partially_delivered | Partially delivered |
delivered | Delivered |
completed | Completed (after-sales window closed) |
canceled | Cancelled |
Deliverables (delivers)
- Returned only when
with_delivers=true; omitted by default to keep responses small. - Each element in the array is one deliverable for one SKU, attributed to an order line via
line_no+sku_id/sku_guid. kinddetermines the structure ofcontent:acct_bundleholds account fields,secret_codeholds a card key, andfile_asset/download_refprovide the file URL viacontent_ref.- For large files or sensitive content,
contentmay be empty; download it usingcontent_refandexpires_at. - Deliverables are available in this endpoint's
delivers; no separate claim endpoint is provided.
Fetching recommendations
- When you know the order number, use
order_no/order_idto fetch exactly one order; - When a single ordering flow produced several orders (splits, retries), use
trace_idto retrieve them all; - Do not poll too aggressively; combine polling with callbacks. The default rate limit is 60 requests per minute.
Errors
| code | Scenario | Action |
|---|---|---|
1001 | None of the three conditions was provided | Pass trace_id, order_no, or order_id |
2001 | Order does not exist | Confirm the order number; for a just-placed order, retry later |
1003 | order.read not enabled | Enable the permission in the portal |
4001 | Rate limit exceeded | Back off per retry_after |