库存 API
实时监控各仓库的库存水平。
接口列表
GET
/inventory
inventory:read
获取所有商品的库存水平。支持按仓库和低库存状态筛选。
GET
/inventory/:productId
inventory:read
获取特定商品在所有仓库的库存信息。
字段参考
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
id | string | 否 | 唯一库存记录ID(只读) |
productId | string | 否 | 商品标识符 |
productSku | string | 否 | 产品SKU |
productName | string | 否 | 商品名称(只读) |
warehouseId | string | 否 | 仓库标识符 |
warehouseName | string | 否 | 仓库名称(只读) |
quantity | integer | 否 | 当前库存数量 |
reservedQuantity | integer | 否 | 待处理订单预留数量 |
availableQuantity | integer | 否 | 可用数量(数量减去预留) |
minThreshold | integer | 否 | 低库存预警阈值 |
updatedAt | datetime | 否 | 最近库存更新时间戳 |
查询参数(列表)
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
page | integer | 否 | 页码(默认:1) |
limit | integer | 否 | 每页条数(默认:20,最大:100) |
warehouseId | string | 否 | 按仓库 ID 筛选 |
lowStock | boolean | 否 | 仅显示低于预警阈值的商品 |
示例
获取库存水平
bash
curl "https://api.mercozy.com/api/v1/external/inventory?lowStock=true" \
-H "X-API-Key: mk_live_your_key_here"获取特定商品库存
bash
curl "https://api.mercozy.com/api/v1/external/inventory/prod_abc123" \
-H "X-API-Key: mk_live_your_key_here"响应示例
json
{
"data": {
"productId": "prod_abc123",
"productName": "Premium Widget",
"sku": "WDG-001",
"quantity": 42,
"lowStockThreshold": 10,
"warehouseId": "wh_main",
"warehouseName": "Main Warehouse",
"updatedAt": "2025-12-15T10:30:00Z"
}
}