首页 > 大数据 > 数据分析 > 一键获取唯品会商品详情,item_getAPI接口讲解
| 参数名 | 类型 | 说明 |
|---|---|---|
| method | String | 固定值: "item_get" |
| app_key | String | 分配的API应用KEY |
| sign | String | 签名,用于验证请求合法性 |
| timestamp | String | 时间戳,格式: yyyy-MM-dd HH:mm:ss |
| item_id | String | 唯品会商品ID |
| 参数名 | 类型 | 说明 |
|---|---|---|
| fields | String | 需要返回的字段,多个字段用逗号分隔 |
| version | String | API版本号,默认为最新版 |
签名(sign)生成步骤:
json{"code": 200,"msg": "success","data": {"item_id": "12345678","title": "商品标题","price": 99.00,"market_price": 199.00,"brand_id": "1001","brand_name": "品牌名称","category_id": "2001","category_name": "分类名称","images": ["http://img.vip.com/image1.jpg","http://img.vip.com/image2.jpg"],"description": "商品描述","stock": 100,"sales": 50,"is_promotion": true,"promotion_info": {"type": "discount","value": "8折","start_time": "2023-01-01 00:00:00","end_time": "2023-01-07 23:59:59"},"delivery_info": {"area": "全国","fee": 0.00,"time": "48小时内发货"},"sku_list": [{"sku_id": "sku001","specs": "颜色:红色,尺寸:M","price": 99.00,"stock": 30},{"sku_id": "sku002","specs": "颜色:蓝色,尺寸:L","price": 99.00,"stock": 20}]}}
json{"code": 400,"msg": "Invalid item_id","data": null}
| 错误码 | 说明 |
|---|---|
| 200 | 请求成功 |
| 400 | 参数错误 |
| 401 | 签名验证失败 |
| 403 | 无权限访问 |
| 404 | 商品不存在 |
| 500 | 服务器内部错误 |
php<?php$app_key = 'your_app_key';$app_secret = 'your_app_secret';$item_id = '12345678';$params = ['method' => 'item_get','app_key' => $app_key,'timestamp' => date('Y-m-d H:i:s'),'item_id' => $item_id];// 生成签名ksort($params);$sign_str = $app_secret;foreach ($params as $key => $value) {$sign_str .= $key . $value;}$sign_str .= $app_secret;$params['sign'] = strtoupper(md5($sign_str));// 发送请求$url = 'https://openapi.vip.com/api?' . http_build_query($params);$response = file_get_contents($url);$result = json_decode($response, true);// 处理结果if ($result['code'] == 200) {$item_info = $result['data'];print_r($item_info);} else {echo "Error: " . $result['msg'];}?>
pythonimport hashlibimport timeimport requestsapp_key = 'your_app_key'app_secret = 'your_app_secret'item_id = '12345678'params = {'method': 'item_get','app_key': app_key,'timestamp': time.strftime('%Y-%m-%d %H:%M:%S'),'item_id': item_id}# 生成签名sorted_params = sorted(params.items(), key=lambda x: x[0])sign_str = app_secret + ''.join([k + v for k, v in sorted_params]) + app_secretsign = hashlib.md5(sign_str.encode('utf-8')).hexdigest().upper()params['sign'] = sign# 发送请求url = 'https://openapi.vip.com/api'response = requests.get(url, params=params)result = response.json()# 处理结果if result['code'] == 200:item_info = result['data']print(item_info)else:print(f"Error: {result['msg']}")
如需更详细的信息,建议查阅唯品会官方API文档或联系唯品会开放平台技术支持。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70046834/viewspace-3093269/ ,如需转载,请注明出处,否则将追究法律责任。