Dujiao-Next API Reference
About 784 words
Dujiao-Next talks to xstock through a fixed set of upstream endpoints. All paths are relative to the adapter URL:
https://api.xstock.example/api/v1/upstreamExcept for callbacks, every request carries three headers:
| Header | Value |
|---|---|
Dujiao-Next-Api-Key | Your xstock API Key |
Dujiao-Next-Timestamp | Unix timestamp in seconds |
Dujiao-Next-Signature | Lowercase hex of HMAC-SHA256(METHOD\nPATH\nTIMESTAMP\nMD5(BODY), Secret) |
PATH excludes the domain and query string; when there is no request body, MD5(BODY) is d41d8cd98f00b204e9800998ecf8427e.
Endpoint overview
| Method | Path | Purpose | xstock command |
|---|---|---|---|
| POST | /ping | Connectivity and signature check; returns site and wallet information | ping |
| GET | /products | Product list (listed products only) | get_goods |
| GET | /products/:id | Product details | get_goods |
| POST | /orders | Create a procurement order; holds funds from the balance | post_order |
| GET | /orders/:id | Query a procurement order | get_orders |
| POST | /orders/:id/cancel | Cancel a procurement order | req_cancel |
| POST | /callback (reverse direction) | Callback pushed by the platform to the shop | Callback event |
The "On this page" list on the right jumps to each endpoint.
POST Connectivity check
Endpoint: POST /ping
Checks whether the URL, key and signature are usable.
The request body may be an empty object. Response fields:
| Field | Description |
|---|---|
site_name | Site name |
balance | Available balance (amount as a string) |
currency | Settlement currency |
member_level | Your tier code; empty when there is no tier scheme |
A 401 means the signature or key is wrong; first check that the Base URL uses /api/v1/upstream.
GET Product list
Endpoint: GET /products
Fetches listed products, with pagination and category filtering.
| Parameter | Description |
|---|---|
page | Page number, starting at 1 |
page_size | Items per page, default 20 |
category_id | Filter by category |
Product fields include: product identifier, title, images, tags, multi-currency prices, minimum order quantity and step, delivery method, and SKU list.
GET Product details
Endpoint: GET /products/:id
Fetches details by product identifier, for cases where a local product mapping already exists but its data needs refreshing.
The response structure matches a single product from /products.
POST Create procurement order
Endpoint: POST /orders
Creates a procurement order, which is equivalent to placing an order with xstock. Request body:
| Field | Required | Description |
|---|---|---|
product_id | Yes | Upstream product identifier |
sku_id | No | Upstream SKU identifier; omit for products without SKUs |
quantity | Yes | Quantity, integer |
downstream_order_no | Yes | Shop-side order number, the idempotency key |
manual_form_data | No | Fields to fill in for manually delivered products |
The response returns the upstream order number and status. Submitting the same downstream_order_no again does not charge twice.
GET Query procurement order
Endpoint: GET /orders/:id
Queries the status of a procurement order by upstream order number.
Returns the aggregate status, the hold and charge state, and the deliverables array (once delivered). Deliverables are attributed by order line and SKU and can be shown to the consumer directly.
POST Cancel procurement order
Endpoint: POST /orders/:id/cancel
Cancels an undelivered procurement order and releases the held amount.
Delivered orders cannot be cancelled and must go through after-sales. The cancellation result is synced to the procurement order and the local order.
POST Status callback
Endpoint: the callback URL that the shop registers for xstock pushes (the shop's /callback)
xstock pushes order status changes to the shop's callback URL, and the shop must respond within 5 seconds:
{ "code": "OK", "msg": "" }Event types: order.accepted, order.fulfilled, order.completed, order.cancelled, order.rejected.
Callback data includes the order identifier, status, order lines and deliverables; for field definitions see Callback events.
Errors and retries
| Scenario | Response | Shop-side handling |
|---|---|---|
| Signature/key error | 401 | Do not retry; check the configuration |
| Invalid parameters | Business error code | Fix the parameters and retry |
| Insufficient balance | Business error code | Top up or reduce the quantity, and inform the user |
| Product delisted/withdrawn | Business error code | Delist the local product |
| Timeout or 5xx | Network error | Retry idempotently with downstream_order_no |
| Unknown result | Timeout | Query the order first, then decide whether to retry |
Mapping to xstock commands
| Upstream endpoint | xstock command | Description |
|---|---|---|
POST /ping | ping | Connectivity |
GET /products, /products/:id | get_goods | Products and SKUs |
POST /orders | post_order | Place an order |
GET /orders/:id | get_orders | Order query, including deliverables |
POST /orders/:id/cancel | req_cancel | Cancel |
| Callback | Webhooks | Status push |
For field-level differences see Dujiao-Next integration; for admin panel steps see Dujiao-Next backend setup.