Query available quantity (get_avail)
About 489 words
Queries the currently sellable quantity by goods, optionally limited to specific SKUs. Use it to display stock in your storefront or to decide whether an order can be placed.
- Permission:
avail.read - Method:
POST - Idempotency: read-only, changes no state
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.
点开字段可查看类型与说明
正在加载交互式结构…
Lookup rules
- Goods: provide at least one of
goods_idandguid; when both are given,guidwins andgoods_idis ignored. - SKUs (optional): pass
skusto query only some SKUs, each identified bysku_idorguid, again withguidtaking precedence. - When
skusis omitted, the sellable status of every SKU under the good is returned and aggregated at goods level.
Request example
{
"id": "shop-a-20261127-avail-001",
"cmd": "get_avail",
"data": {
"items": [
{
"goods_id": 501,
"guid": "9a1b2c3d4e5f60718293a4b5c6d7e8f9",
"skus": [
{ "sku_id": 1001, "guid": "5d8f2a6c9e1b4d3f8a7c0e2b5d9f1a3c" }
]
},
{
"guid": "4c7e1a9d2b5f4e8a9c3d6b1e7f2a5c8d"
}
]
},
"stamp": 1795000000
}| Field | Description |
|---|---|
items | Goods to query, 1–20 |
items[].goods_id / guid | Either one; guid takes precedence |
items[].skus | Optional; at most 100 SKUs; omit it to query all of them |
Response example
{
"id": "shop-a-20261127-avail-001",
"cmd": "get_avail",
"code": 0,
"msg": "",
"data": {
"checked_at": "2026-11-27T01:10:00Z",
"items": [
{
"goods_id": 501,
"guid": "9a1b2c3d4e5f60718293a4b5c6d7e8f9",
"sellable": true,
"available_qty": "18",
"min_qty": 1,
"max_qty": 20,
"per": 1,
"checked_at": "2026-11-27T01:10:00Z",
"skus": [
{
"sku_id": 1001,
"guid": "5d8f2a6c9e1b4d3f8a7c0e2b5d9f1a3c",
"sellable": true,
"available_qty": "18",
"min_qty": 1,
"max_qty": 20,
"per": 1,
"checked_at": "2026-11-27T01:10:00Z"
}
]
}
]
},
"stamp": 1795000001
}The goods-level available_qty is the sum of its sellable SKUs; min_qty / max_qty / per match the goods list and are meant for pre-order validation; do not show a buy button when sellable=false.
Semantics
- The response is a point-in-time snapshot and does not reserve stock; whether an order succeeds still depends on the order acceptance result.
- Never overstate when you cannot be sure: returning 0 is better than treating an uncertain quantity as sellable.
- For goods without SKUs (single SKU),
skusis an empty array and the goods-levelavailable_qtyis the quantity of that good. - Do not replace caching with high-frequency polling: the default rate limit is 60 requests per minute, and exceeding it returns
4001.
Display recommendations
| Quantity | Storefront display |
|---|---|
sellable=false | Show "Out of stock" and disable purchase |
available_qty ≥ 1 | Show as available, or display "In stock" |
| A large quantity | Consider hiding the exact number to avoid price comparison and bulk buying |
Errors
| code | Scenario | Action |
|---|---|---|
1003 | avail.read not enabled | Enable the permission in the portal |
1001 | items is empty or has more than 20 entries, or skus has more than 100 | Adjust the number of items queried |
3002 | The same good appears more than once in items | Merge them into one entry |
4001 | Rate limit exceeded | Back off per retry_after |