商品 API

创建、查询、更新和删除商品目录中的商品。

接口列表
GET

/products

products:read

获取商品分页列表。支持按状态、分类和关键词筛选。

GET

/products/:id

products:read

根据 ID 获取单个商品。

POST

/products

products:write

在商品目录中创建新商品。

PUT

/products/:id

products:write

更新现有商品。支持部分更新。

DELETE

/products/:id

products:write

软删除商品。可在 30 天内恢复。

字段参考
字段类型必填描述

id

string

唯一商品标识符(只读)

sku

string

库存单位编码

name

string

商品名称

description

string

商品描述(支持 HTML)

barcode

string

产品主条码(UPC/EAN)

brand

string

产品品牌名称

categoryId

string

分类标识符

unitPrice

integer

价格(单位:分,例如 1999 = $19.99)

normalPrice

integer

原价/标价(单位:分,用于显示折扣)

purchasePrice

integer

采购价/成本价(单位:分)

weight

string

重量(克)

isActive

boolean

产品是否激活/已发布(默认:true)

stockTotal

integer

所有仓库的总可用库存(只读)

images

string[]

产品图片URL

createdAt

datetime

ISO 8601 时间戳(只读)

updatedAt

datetime

ISO 8601 时间戳(只读)

查询参数(列表)
字段类型必填描述

page

integer

页码(默认:1)

limit

integer

每页条数(默认:20,最大:100)

示例
分页获取商品列表
bash
curl "https://api.mercozy.com/api/v1/external/products?page=1&limit=10" \
  -H "X-API-Key: mk_live_your_key_here"
创建商品
bash
curl -X POST "https://api.mercozy.com/api/v1/external/products" \
  -H "X-API-Key: mk_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "sku": "WDG-001",
    "name": "Premium Widget",
    "unitPrice": 2999,
    "normalPrice": 3999,
    "brand": "Acme Corp",
    "isActive": true
  }'