以下是微店商品详情API接口的典型JSON返回数据结构说明,基于公开的微店开放平台API文档和常见电商API设计模式整理。实际使用时请以微店官方最新文档为准。
1. 接口基本信息
- 请求方式:
GET
或POST
- 接口地址:
https://api.vdian.com/api?public
(示例,具体需参考官方文档) - 必填参数:
method
:vdian.item.get
(获取商品详情)access_token
: 授权Tokenitem_id
: 商品ID
2. JSON返回数据结构
成功响应示例
json { "status": { "status_code": 0, "status_reason": "success" }, "result": { "item": { "item_id": "123456789", "title": "商品标题", "subtitle": "商品副标题", "price": 99.9, "original_price": 199.9, "stock": 100, "sold": 50, "status": 1, "images": [ "http://img.weidian.com/item/1.jpg", "http://img.weidian.com/item/2.jpg" ], "description": "<div>商品详细描述HTML</div>", "skus": [ { "sku_id": "sku123", "specs": [ {"name": "颜色", "value": "红色"}, {"name": "尺寸", "value": "M"} ], "price": 99.9, "stock": 20, "sku_image": "http://img.weidian.com/sku/1.jpg" } ], "category": { "id": "cate123", "name": "服装" }, "shop": { "shop_id": "shop456", "name": "微店名称", "logo": "http://img.weidian.com/shop/logo.jpg" }, "postage": 10.0, "is_free_postage": false, "created": 1672502400, "modified": 1673020800 } } }
失败响应示例
json { "status": { "status_code": 40001, "status_reason": "invalid item_id" } }
3. 字段详细说明
顶层字段
字段 | 类型 | 说明 |
status |
Object | 接口调用状态 |
result |
Object | 返回的业务数据 |
status 对象
字段 | 类型 | 说明 |
status_code |
Int | 状态码(0表示成功) |
status_reason |
String | 状态描述(如"success"或错误原因) |
result.item 对象(商品详情)
字段 | 类型 | 说明 |
item_id |
String | 商品唯一ID |
title |
String | 商品标题 |
subtitle |
String | 商品副标题(可选) |
price |
Float | 当前价格 |
original_price |
Float | 原价(可选) |
stock |
Int | 总库存 |
sold |
Int | 已售数量 |
status |
Int | 商品状态(1:在售, 0:下架) |
images |
Array | 商品图片URL数组 |
description |
String | 商品描述(HTML格式) |
skus |
Array | SKU列表(见下文) |
category |
Object | 商品分类信息 |
shop |
Object | 店铺信息 |
postage |
Float | 运费(单位:元) |
is_free_postage |
Boolean | 是否包邮 |
created |
Int | 创建时间(Unix时间戳) |
modified |
Int | 最后修改时间(Unix时间戳) |
skus 数组中的对象
字段 | 类型 | 说明 |
sku_id |
String | SKU唯一ID |
specs |
Array | 规格属性数组(每个规格包含name 和value ) |
price |
Float | SKU价格 |
stock |
Int | SKU库存 |
sku_image |
String | SKU特有图片URL(可选) |
category 对象
字段 | 类型 | 说明 |
id |
String | 分类ID |
name |
String | 分类名称 |
shop 对象
字段 | 类型 | 说明 |
shop_id |
String | 店铺ID |
name |
String | 店铺名称 |
logo |
String | 店铺Logo URL |
4. Python采集代码示例
python import requests import json def get_weidian_item(item_id, access_token): url = "https://api.vdian.com/api" params = { "method": "vdian.item.get", "access_token": access_token, "item_id": item_id, "version": "1.0" } try: response = requests.get(url, params=params) data = response.json() if data["status"]["status_code"] == 0: return data["result"]["item"] else: print(f"API Error: {data['status']['status_reason']}") return None except Exception as e: print(f"Request failed: {str(e)}") return None # 示例调用 item_data = get_weidian_item("123456789", "your_access_token") if item_data: print(json.dumps(item_data, indent=2, ensure_ascii=False))