我们常在软件开发或合作中遇到“API”这个词,比如API接口、API调用、API接口函数等等,那么到底什么是API呢?API用通俗的话说,就相当于大家经常看的科幻电影中的空间站或宇宙飞船与其他航天设备对接的那个开口。别人的航天飞机要跟你对接时,你必须告诉你的空间站的对外接口标准规格,比如接口名称、接口尺寸、接口程序等等,才能保证最终两者顺利通过这个接口建立联系,完成彼此内容的交换。
什么是API接口?API是指应用程序编程接口,我们通过API接口可以实现特定的功能,而不需要了解其内部实现细节。API的标准说法是ApplicationProgrammingInterface,即应用程序编程接口。POSIX标准是由IEEE和ISO/IEC共同开发的标准系统。
苏宁的API开发接口,我们需要做下面几件事情。
1)开放平台注册开发者账号;
2)然后为每个淘宝应用注册一个应用程序键(App Key) ;
3)下载苏宁API的SDK并掌握基本的API基础知识和调用;
4)利用SDK接口和对象,传入AppKey或者必要的时候获取并传入SessionKey来进行程序开发;
5)利用苏宁平台的文档中心和API测试工具,对接口进行测试。从而了解返回信息,方便程序获取。
代码如下:
Result Object:
---------------------------------------
{
"item": {
"num_iid": "0070134261/703410301",
"title": "罗技(Logitech) M235 无线光电鼠标2代 升级优联技术台式笔记本电脑无线办公省电鼠标 (灰色)",
"desc_short": "",
"price": "45.00",
"total_price": 0,
"suggestive_price": 0,
"orginal_price": "",
"nick": null,
"num": "99",
"min_num": 0,
"detail_url": "http://product.suning.com/0070134261/703410301.html",
"pic_url": "//image.suning.cn/uimg/b2c/newcatentries/0070134261-000000000703410301_1.jpg_400w_400h_4e",
"brand": null,
"brandId": null,
"rootCatId": null,
"cid": null,
"crumbs": {
"0": "电脑/办公/外设",
"157237": "电脑外设",
"157250": "鼠标"
},
"created_time": "",
"modified_time": "",
"delist_time": "",
"desc": "",
"desc_img": [
"https://image.suning.cn/uimg/sop/commodity/180469403026839773750900_x.jpg",
"//image.suning.cn/uimg/sop/commodity/829807810124167623648200_x.jpg",
"//image.suning.cn/uimg/sop/commodity/186865161514348058123327_x.jpg",
"//image.suning.cn/uimg/sop/commodity/131542364233716381943090_x.jpg",
"//image.suning.cn/uimg/sop/commodity/763953680205707567428220_x.jpg",
"//image.suning.cn/uimg/sop/commodity/414487999203006843787490_x.jpg",
"//image.suning.cn/uimg/sop/commodity/861748885456060517999000_x.jpg",
"//image.suning.cn/uimg/sop/commodity/953397344178553966030960_x.jpg",
"//image.suning.cn/uimg/sop/commodity/210232585971362766796270_x.jpg",
"//image.suning.cn/uimg/sop/commodity/101179711710153822981808_x.jpg",
"//image.suning.cn/uimg/sop/commodity/199857039911322248487598_x.jpg",
"//image.suning.cn/uimg/sop/commodity/957732684206097424622610_x.jpg",
"//image.suning.cn/uimg/sop/commodity/181933260774892681354540_x.jpg",
"//image.suning.cn/uimg/sop/commodity/213219414110141579504563_x.jpg"
],
"item_imgs": [
{
"url": "//image.suning.cn/uimg/b2c/newcatentries/0070134261-000000000703410301_1.jpg_800w_800h_4e"
},
{
"url": "//image.suning.cn/uimg/b2c/newcatentries/0070134261-000000000703410301_2.jpg_800w_800h_4e"
},
{
"url": "//image.suning.cn/uimg/b2c/newcatentries/0070134261-000000000703410301_3.jpg_800w_800h_4e"
},
{
"url": "//image.suning.cn/uimg/b2c/newcatentries/0070134261-000000000703410301_4.jpg_800w_800h_4e"
},
{
"url": "//image.suning.cn/uimg/b2c/newcatentries/0070134261-000000000703410301_5.jpg_800w_800h_4e"
}
],
"item_weight": "",
"item_size": "",
"location": "",
"post_fee": "",
"express_fee": "",
"ems_fee": "",
"shipping_to": "",
"has_discount": "",
"video": [],
"is_virtual": "",
"sample_id": "",
"is_promotion": "",
"props_name": "0:0:颜色:罗技M170灰色;0:1:颜色:罗技M170蓝色;0:2:颜色:罗技M170红色;0:3:颜色:罗技M171黑色;0:4:颜色:罗技M171蓝色;0:5:颜色:罗技M171红色;0:6:颜色:罗技M186黑色灰边;0:7:颜色:罗技M186黑色红边;0:8:颜色:罗技M186黑色蓝边;0:9:颜色:罗技M235黑色;0:10:颜色:罗技M280黑色;0:11:颜色:罗技M280蓝色;0:12:颜色:罗技M280红色;0:13:颜色:罗技M280灰色;0:14:颜色:罗技M325黑色;0:15:颜色:罗技M650黑色;0:16:颜色:罗技M650白色;0:17:颜色:罗技M650粉色;0:18:颜色:罗技M650L黑色;0:19:颜色:罗技M650L白色",
"prop_imgs": {
"prop_img": []
},
"property_alias": "0:0:罗技M170灰色;0:1:罗技M170蓝色;0:2:罗技M170红色;0:3:罗技M171黑色;0:4:罗技M171蓝色;0:5:罗技M171红色;0:6:罗技M186黑色灰边;0:7:罗技M186黑色红边;0:8:罗技M186黑色蓝边;0:9:罗技M235黑色;0:10:罗技M280黑色;0:11:罗技M280蓝色;0:12:罗技M280红色;0:13:罗技M280灰色;0:14:罗技M325黑色;0:15:罗技M650黑色;0:16:罗技M650白色;0:17:罗技M650粉色;0:18:罗技M650L黑色;0:19:罗技M650L白色",
"props": [
{
"name": "品牌",
"value": "罗技(Logitech)"
},
{
"name": "鼠标产品类型",
"value": "办公鼠标,蓝牙鼠标"
},
{
"name": "产品型号",
"value": "罗技M235"
},
{
"name": "颜色",
"value": "灰色"
},
{
"name": "适用类型",
"value": "笔记本便携,办公"
},
{
"name": "供电模式",
"value": "五号电池"
},
{
"name": "鼠标接口",
"value": "USB"
},
{
"name": "工作方式",
"value": "光电"
},
{
"name": "人体工学",
"value": "是"
},
{
"name": "按键数",
"value": "2"
}
],
"total_sold": "",
"skus": {
"sku": [
{
"price": "45.00",
"orginal_price": null,
"properties": "0:0;",
"properties_name": "0:0:颜色:罗技M170灰色",
"sku_id": "000000010535842005"
},
{
"price": "45.00",
"orginal_price": null,
"properties": "0:1;",
"properties_name": "0:1:颜色:罗技M170蓝色",
"sku_id": "000000010535855478"
},
{
"price": "45.00",
"orginal_price": null,
"properties": "0:2;",
"properties_name": "0:2:颜色:罗技M170红色",
"sku_id": "000000010535847232"
},
{
"price": "49.00",
"orginal_price": null,
"properties": "0:3;",
"properties_name": "0:3:颜色:罗技M171黑色",
"sku_id": "000000000702044852"
},
{
"price": "49.00",
"orginal_price": null,
"properties": "0:4;",
"properties_name": "0:4:颜色:罗技M171蓝色",
"sku_id": "000000000702054145"
},
{
"price": "49.00",
"orginal_price": null,
"properties": "0:5;",
"properties_name": "0:5:颜色:罗技M171红色",
"sku_id": "000000000702050066"
},
{
"price": "49.00",
"orginal_price": null,
"properties": "0:6;",
"properties_name": "0:6:颜色:罗技M186黑色灰边",
"sku_id": "000000000702296951"
},
{
"price": "49.00",
"orginal_price": null,
"properties": "0:7;",
"properties_name": "0:7:颜色:罗技M186黑色红边",
"sku_id": "000000000702300333"
},
{
"price": "55.00",
"orginal_price": null,
"properties": "0:8;",
"properties_name": "0:8:颜色:罗技M186黑色蓝边",
"sku_id": "000000000702301626"
},
{
"price": "79.00",
"orginal_price": null,
"properties": "0:9;",
"properties_name": "0:9:颜色:罗技M235黑色",
"sku_id": "000000000703410301"
},
{
"price": "69.00",
"orginal_price": null,
"properties": "0:10;",
"properties_name": "0:10:颜色:罗技M280黑色",
"sku_id": "000000000702191572"
},
{
"price": "69.00",
"orginal_price": null,
"properties": "0:11;",
"properties_name": "0:11:颜色:罗技M280蓝色",
"sku_id": "000000000702205116"
},
{
"price": "69.00",
"orginal_price": null,
"properties": "0:12;",
"properties_name": "0:12:颜色:罗技M280红色",
"sku_id": "000000000702208226"
},
{
"price": "69.00",
"orginal_price": null,
"properties": "0:13;",
"properties_name": "0:13:颜色:罗技M280灰色",
"sku_id": "000000000702210716"
},
{
"price": "89.00",
"orginal_price": null,
"properties": "0:14;",
"properties_name": "0:14:颜色:罗技M325黑色",
"sku_id": "000000000105021656"
},
{
"price": "229.00",
"orginal_price": null,
"properties": "0:15;",
"properties_name": "0:15:颜色:罗技M650黑色",
"sku_id": "000000012356492176"
},
{
"price": "229.00",
"orginal_price": null,
"properties": "0:16;",
"properties_name": "0:16:颜色:罗技M650白色",
"sku_id": "000000012356492094"
},
{
"price": "229.00",
"orginal_price": null,
"properties": "0:17;",
"properties_name": "0:17:颜色:罗技M650粉色",
"sku_id": "000000012356492144"
},
{
"price": "229.00",
"orginal_price": null,
"properties": "0:18;",
"properties_name": "0:18:颜色:罗技M650L黑色",
"sku_id": "000000012356492259"
},
{
"price": "229.00",
"orginal_price": null,
"properties": "0:19;",
"properties_name": "0:19:颜色:罗技M650L白色",
"sku_id": "000000012356492215"
}
]
},
"seller_id": "",
"sales": 0,
"shop_id": "70134261",
"props_list": {
"0:0": "颜色:罗技M170灰色",
"0:1": "颜色:罗技M170蓝色",
"0:2": "颜色:罗技M170红色",
"0:3": "颜色:罗技M171黑色",
"0:4": "颜色:罗技M171蓝色",
"0:5": "颜色:罗技M171红色",
"0:6": "颜色:罗技M186黑色灰边",
"0:7": "颜色:罗技M186黑色红边",
"0:8": "颜色:罗技M186黑色蓝边",
"0:9": "颜色:罗技M235黑色",
"0:10": "颜色:罗技M280黑色",
"0:11": "颜色:罗技M280蓝色",
"0:12": "颜色:罗技M280红色",
"0:13": "颜色:罗技M280灰色",
"0:14": "颜色:罗技M325黑色",
"0:15": "颜色:罗技M650黑色",
"0:16": "颜色:罗技M650白色",
"0:17": "颜色:罗技M650粉色",
"0:18": "颜色:罗技M650L黑色",
"0:19": "颜色:罗技M650L白色"
},
"seller_info": {
"nick": null,
"city": null,
"shopid": "70134261",
"shopname": null,
"title": null,
"zhuy": "https://shop.suning.com/70134261/index.html",
"tel": null
},
"tmall": "false",
"error": "",
"warning": "",
"url_log": [],
"sold": 0,
"props_img": [],
"shopinfo": {
"shop_name": null
},
"format_check": "ok",
"shop_item": [],
"relate_items": []
},
"error": "",
"secache": "18f19fa8b522b37c105e7cfb8a9c5b9d",
"secache_time": 1657851619,
"secache_date": "2022-07-15 10:20:19",
"translate_status": "error",
"translate_time": 0.001,
"language": {
"current_lang": "cn",
"source_lang": "zh-CN"
},
"reason": "",
"error_code": "0000",
"cache": 0,
"api_info": "today:12 max:10100 all[49=12+20+17];expires:2030-12-31",
"execution_time": "2.144",
"server_time": "Beijing/2022-07-15 10:20:19",
"client_ip": "106.6.38.1",
"call_args": {
"num_iid": "0070134261/703410301"
},
"api_type": "suning",
"translate_language": "zh-CN",
"translate_engine": "google_new",
"server_memory": "3.27MB",
"request_id": "gw-1.62d0cee1cd247",
"last_id": "1079059825"
}
名称 | 类型 | 必须 | 描述 |
---|---|---|---|
key | String | 是 | 调用key(必须以GET方式拼接在URL中) |
secret | String | 是 | 调用密钥 |
api_name | String | 是 | API接口名称(包括在请求地址中)[item_search,item_get,item_search_shop等] |
cache | String | 否 | [yes,no]默认yes,将调用缓存的数据,速度比较快 |
result_type | String | 否 | [json,jsonu,xml,serialize,var_export]返回数据格式,默认为json,jsonu输出的内容中文可以直接阅读 |
lang | String | 否 | [cn,en,ru]翻译语言,默认cn简体中文 |
version | String | 否 | API版本 |
请求参数
请求参数:num_iid=0070134261/703410301
参数说明:num_iid:店铺ID/商品ID
响应参数
Version: Date:
名称 | 类型 | 必须 | 示例值 | 描述 |
---|---|---|---|---|
num_iid |
Bigint | 0 | 10228868562 | 商品ID |
title |
String | 0 | 百慕爱BAIMUAI休闲鞋 女2019春季 透气 时尚 推荐舒适增高运动鞋女板鞋女英伦小白鞋女学生磨砂皮女鞋 | 商品标题 |
desc_short |
String | 0 | 秋冬新款 热销推荐 | 商品简介 |
price |
Int | 0 | 0 | 价格 |
total_price |
Int | 0 | 0 | |
suggestive_price |
Int | 0 | 0 | |
orginal_price |
Int | 0 | 0 | 原价 |
nick |
String | 0 | 卖家昵称 | |
num |
Int | 0 | 99 | |
min_num |
Int | 0 | 0 | |
detail_url |
String | 0 | http://product.suning.com/0070089297/10228868562.html | 商品链接 |
pic_url |
String | 0 | //imgservice.suning.cn/uimg1/b2c/image/9mYpQTuKpP6YfYQ0KEgafA.jpg_800w_800h_4e | 商品图片 |
brand |
String | 0 | 品牌名称 | |
brandId |
String | 0 | 品牌ID | |
rootCatId |
String | 0 | 顶级分类ID | |
cid |
String | 0 | ||
crumbs |
Mix | 0 | {"0": "服装鞋帽", "340557": "女鞋", "501404": "女士帆布鞋"} | 导航列表 |
created_time |
String | 0 | ||
modified_time |
String | 0 | ||
delist_time |
String | 0 | ||
desc |
String | 0 | ||
desc_img |
Mix | 0 | ["//uimgproxy.suning.cn/uimg1/sop/commodity/gsVgSK_aShsXbB2fgGg7fA.png"] | 商品描述图片 |
item_imgs |
Mix | 0 | [//imgservice.suning.cn/uimg1/b2c/image/9mYpQTuKpP6YfYQ0KEgafA.jpg_800w_800h_4e] | 商品图片 |
item_weight |
String | 0 | ||
item_size |
String | 0 | ||
location |
String | 0 | 发货地 | |
post_fee |
String | 0 | 物流费用 | |
express_fee |
String | 0 | 快递费用 | |
ems_fee |
String | 0 | EMS费用 | |
shipping_to |
String | 0 | 发货至 | |
has_discount |
String | 0 | ||
video |
Mix | 0 | [] | 商品视频 |
is_virtual |
String | 0 | ||
sample_id |
String | 0 | 商品风格标识ID | |
is_promotion |
String | 0 | ||
props_name |
String | 0 | color-ex:08:颜色:白色;color-ex:09:颜色:黑色;buytype:16:尺码:35码 | 商品属性名 |
prop_imgs |
Mix | 0 | {"prop_img": []} | 商品属性图片列表 |
property_alias |
String | 0 | color-ex:08:白色;buytype:16:35码 | 商品属性别名 |
props |
Mix | 0 | [] | 商品详情 |
total_sold |
String | 0 | ||
skus |
Mix | 0 | {"sku": [{"price": null, "orginal_price": "", "properties": "color-ex:08;buytype:16", "properties_name": "color-ex:08:颜色:白色;buytype:16:尺码:35码", "quantity": 0, "sku_id": 0 }] } | 商品规格信息 |
seller_id |
String | 0 | 卖家ID | |
sales |
String | 0 | 销量 | |
shop_id |
String | 0 | 店铺ID | |
props_list |
Mix | 0 | {"color-ex:08": "颜色:白色","buytype:16": "尺码:35码"} | 商品属性 |
seller_info |
Mix | 0 | {"nick": "", "city": null, "level": "", "rate": "", "totle_pf": null, "desc_pf": null, "server_pf": null, "send_pf": null, "shop_type": "", "user_num_id": "", "shopid": "", "shopname": "", "shop_href": "http://shop.suning.com/", "tel": null, "menu": [] } | 卖家信息 |
tmall |
Boolean | 0 | 是否天猫 | |
error |
String | 0 | 错误信息 | |
warning |
String | 0 | 警告信息 | |
url_log |
String | 0 | ||
sold |
Int | 0 | 0 | |
props_img |
Mix | 0 | [] | |
shopinfo |
String | 0 | {"shop_name": ""} | 店铺信息 |
shop_item |
Mix | 0 | [] | |
relate_items |
Mix | 0 | [] |
请求示例
-- 请求示例 url 默认请求参数已经URL编码处理 curl -i "https://api-gw.onebound.cn/suning/item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=0070134261/703410301"
响应示例
异常示例
相关资料
错误码解释
状态代码(error_code) | 状态信息 | 详细描述 | 是否收费 |
---|---|---|---|
0000 | success | 接口调用成功并返回相关数据 | 是 |
2000 | Search success but no result | 接口访问成功,但是搜索没有结果 | 是 |
4000 | Server internal error | 服务器内部错误 | 否 |
4001 | Network error | 网络错误 | 否 |
4002 | Target server error | 目标服务器错误 | 否 |
4003 | Param error | 用户输入参数错误 | 忽略 |
4004 | Account not found | 用户帐号不存在 | 忽略 |
4005 | Invalid authentication credentials | 授权失败 | 忽略 |
4006 | API stopped | 您的当前API已停用 | 忽略 |
4007 | Account stopped | 您的账户已停用 | 忽略 |
4008 | API rate limit exceeded | 并发已达上限 | 忽略 |
4009 | API maintenance | API维护中 | 忽略 |
4010 | API not found with these values | API不存在 | 忽略 |
4012 | Please add api first | 请先添加api | 忽略 |
4013 | Number of calls exceeded | 调用次数超限 | 忽略 |
4014 | Missing url param | 参数缺失 | 忽略 |
4015 | Wrong pageToken | 参数pageToken有误 | 忽略 |
4016 | Insufficient balance | 余额不足 | 忽略 |
4017 | timeout error | 请求超时 | 否 |
5000 | unknown error | 未知错误 | 否 |
以上是一般苏宁API应用开发的关键流程,其中通过苏宁文档中心和API测试工具,进行概念了解和接口信息查询很重要。因为这些数据就是我们需要在逐步显示出来的
苏宁易购获得suning商品详情 API 返回值说明
API测试注册地址:登录 - 跨境电商平台接口提供商 数据采集公司 数据接口定制服务 企业级数据服务商
请求地址: https://api-gw.onebound.cn/suning/item_get