蘑菇街商品详情接口技术解析
一、接口功能说明
商品详情接口用于获取商品基础信息、SKU数据、促销活动等核心数据,支持以下功能:
-
基础信息:标题、价格、主图等
-
商品属性:颜色、尺码等SKU规格
-
营销信息:满减、折扣等促销活动
-
店铺信息:店铺名称、评分等
点击获取key和secret
二、接口核心参数
public class ProductRequest {@NotNullprivate Long itemId; // 商品IDprivate Boolean needSku = true; // 是否需要SKU数据private Boolean needPromotion = false; // 是否需要促销信息private String clientType = "H5"; // 客户端类型
}
三、Java调用示例
@RestController
@RequestMapping("/api/product")
public class ProductController {@Autowiredprivate MogujieApiClient apiClient;@GetMapping("/detail")public Response<ProductDetail> getDetail(@Valid ProductRequest request) {// 构建签名参数Map<String, String> params = new HashMap<>();params.put("item_id", request.getItemId().toString());params.put("timestamp", System.currentTimeMillis());// 调用蘑菇街开放平台APIString response = apiClient.call("/item/get_detail",params,request.getClientType());return JSON.parseObject(response, ProductDetail.class);}
}
四、响应数据结构
{"code": 200,"data": {"item_id": "123456","title": "春季新款女装","price": 19900,"skus": [{"sku_id": "789","spec": "红色/M码","stock": 100}],"promotions": [{"type": "discount","discount": "8折"}]}
}
五、注意事项
-
需申请API权限密钥
-
每日调用限额5000次
-
建议使用本地缓存减少API调用
-
重要字段需要HTTPS传输加密