一、背景介绍
随着移动互联网的快速发展,微信小程序作为一种新型的电商形态,正逐渐成为广大商家拓展销售渠道、提升品牌影响力的重要平台。然而,对于许多传统企业而言,如何将商品信息快速、准确地铺货到微信小程序自营商城是一个亟待解决的问题。为了解决这一痛点,本文将介绍如何使用1688往微信小程序自营商城铺货商品采集API接口来实现这一目标。
二、接口概述
1688往微信小程序自营商城铺货商品采集API接口是一种基于HTTP协议的RESTful风格接口,提供了一组GET、POST、PUT、DELETE等HTTP方法,用于实现商品信息的采集、更新、删除等操作。通过该接口,商家可以将1688平台上的商品信息快速、准确地同步到微信小程序自营商城中,提高商品信息的一致性和管理效率。
三、接口设计
- 商品信息采集接口
为了实现商品信息的采集,我们设计了一个GET方法,用于获取1688平台上的商品列表。接口地址为:https://api.example.com/products,其中"example.com"为接口提供方的域名。在调用该接口时,需要传入一个查询参数"source=1688",表示从1688平台采集商品信息。
1、获取商品列表商品ID接口:item_search-按关键字搜索商品
2、获取商品详情信息接口:item_get 通过商品ID获取到商品详情页数据,包括商品sku、图片、详情图等。API测试入口
- 商品信息更新接口
为了实现商品信息的更新,我们设计了一个PUT方法,用于将更新后的商品信息提交到微信小程序自营商城。接口地址为:https://api.example.com/products/{product_id},其中"{product_id}"为商品ID。在调用该接口时,需要传入商品的更新信息,包括商品名称、描述、价格等字段。
- 商品信息删除接口
为了实现商品信息的删除,我们设计了一个DELETE方法,用于将指定ID的商品从微信小程序自营商城中删除。接口地址为:https://api.example.com/products/{product_id},其中"{product_id}"为商品ID。在调用该接口时,需要传入待删除商品的ID。
php
"item": {
"num_iid": "577134119803",
"title": "曼龙咘咘同款儿童沙发婴儿卡通女孩男孩宝宝懒人座椅小沙发公主凳",
"desc_short": "",
"price": "293.00",
"total_price": 0,
"suggestive_price": 0,
"orginal_price": "293.00",
"nick": "安吉曼龙家居用品有限公司",
"num": "80049",
"min_num": "1",
"detail_url": "https://detail.1688.com/offer/577134119803.html",
"pic_url": "https://cbu01.alicdn.com/img/ibank/13060019448_400746914.jpg",
"brand": "",
"brandId": "",
"rootCatId": "13",
"cid": "122208004",
"crumbs": [],
"created_time": "",
"modified_time": "",
"delist_time": "",
"desc": "<div id=\"offer-template-0\"></div><p><img src=\"https://cbu01.alicdn.com/img/ibank/2020/316/990/20279099613_400746914.jpg\" alt=\"公告\"/><img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01ptiBYP1hqGyQYTK2j_!!3978704328-0-cib.jpg?__r__=1670746966357\" alt=\"undefined\"/><br class=\"img-brk\"/><img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01vVW9LV1hqGyLwvA92_!!3978704328-0-cib.jpg?__r__=1670746966357\" alt=\"undefined\"/><br class=\"img-brk\"/><img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01LoIfe71hqGyThqGBS_!!3978704328-0-cib.jpg?__r__=1670746966357\" alt=\"undefined\"/><br class=\"img-brk\"/><img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01ktByau1hqGyVWO9GN_!!3978704328-0-cib.jpg?__r__=1670746966358\" alt=\"undefined\"/><br class=\"img-brk\"/><img src=\"https://cbu01.alicdn.com/img/ibank/O1CN010GTXbQ1hqGyUohKsl_!!3978704328-0-cib.jpg?__r__=1670746966358\" alt=\"undefined\"/><br class=\"img-brk\"/><img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01JfwJ4J1hqGyMiPLIs_!!3978704328-0-cib.jpg?__r__=1670746966358\" alt=\"undefined\"/><br class=\"img-brk\"/><img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01c40C4g1hqGyQYUvrj_!!3978704328-0-cib.jpg?__r__=1670746966358\" alt=\"undefined\"/><br class=\"img-brk\"/><img src=\"https://cbu01.alicdn.com/img/ibank/O1CN012vl9GV1hqGyPXo3AR_!!3978704328-0-cib.jpg?__r__=1670746966358\" alt=\"undefined\"/><br class=\"img-brk\"/><img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01iF6BgC1hqGyT0DHKs_!!3978704328-0-cib.jpg?__r__=1670746966358\" alt=\"undefined\"/><br class=\"img-brk\"/><img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01oX4Gh11hqGyThrjhW_!!3978704328-0-cib.jpg?__r__=1670746966358\" alt=\"undefined\"/><br class=\"img-brk\"/><img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01xfF6QU1hqGyXYbo7j_!!3978704328-0-cib.jpg?__r__=1670746974608\" alt=\"undefined\"/><br class=\"img-brk\"/><img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01Mh0KDW1hqGyT0EYL6_!!3978704328-0-cib.jpg?__r__=1670746974608\" alt=\"undefined\"/></p><img src=\"https://www.o0b.cn/i.php?t.png&rid=gw-4.6552e92c0cbd4&p=3702633966&k=31029&t=1699932461\" style=\"display:none\" />",
"desc_img": [
"https://cbu01.alicdn.com/img/ibank/2020/316/990/20279099613_400746914.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01ptiBYP1hqGyQYTK2j_!!3978704328-0-cib.jpg?__r__=1670746966357",
"https://cbu01.alicdn.com/img/ibank/O1CN01vVW9LV1hqGyLwvA92_!!3978704328-0-cib.jpg?__r__=1670746966357",
"https://cbu01.alicdn.com/img/ibank/O1CN01LoIfe71hqGyThqGBS_!!3978704328-0-cib.jpg?__r__=1670746966357",
"https://cbu01.alicdn.com/img/ibank/O1CN01ktByau1hqGyVWO9GN_!!3978704328-0-cib.jpg?__r__=1670746966358",
"https://cbu01.alicdn.com/img/ibank/O1CN010GTXbQ1hqGyUohKsl_!!3978704328-0-cib.jpg?__r__=1670746966358",
"https://cbu01.alicdn.com/img/ibank/O1CN01JfwJ4J1hqGyMiPLIs_!!3978704328-0-cib.jpg?__r__=1670746966358",
"https://cbu01.alicdn.com/img/ibank/O1CN01c40C4g1hqGyQYUvrj_!!3978704328-0-cib.jpg?__r__=1670746966358",
"https://cbu01.alicdn.com/img/ibank/O1CN012vl9GV1hqGyPXo3AR_!!3978704328-0-cib.jpg?__r__=1670746966358",
"https://cbu01.alicdn.com/img/ibank/O1CN01iF6BgC1hqGyT0DHKs_!!3978704328-0-cib.jpg?__r__=1670746966358",
"https://cbu01.alicdn.com/img/ibank/O1CN01oX4Gh11hqGyThrjhW_!!3978704328-0-cib.jpg?__r__=1670746966358",
"https://cbu01.alicdn.com/img/ibank/O1CN01xfF6QU1hqGyXYbo7j_!!3978704328-0-cib.jpg?__r__=1670746974608",
"https://cbu01.alicdn.com/img/ibank/O1CN01Mh0KDW1hqGyT0EYL6_!!3978704328-0-cib.jpg?__r__=1670746974608"
],
"item_imgs": [
{
"url": "https://cbu01.alicdn.com/img/ibank/13060019448_400746914.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/13060010640_400746914.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/12980196618_400746914.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/O1CN010ZjN8A1hqGxzkEntQ_!!3978704328-0-cib.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01RIPTyx1hqGy5pb1lX_!!3978704328-0-cib.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01YhhIRL1hqH3lgzj4p_!!3978704328-0-cib.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01b8uIbO1hqH419LUhC_!!3978704328-0-cib.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/13059989792_400746914.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01q1RaO91hqGxDRk1Tu_!!3978704328-0-cib.jpg"
}
],
"item_weight": "",
"item_size": "",
"location": "浙江湖州",
"post_fee": 0,
"express_fee": "",
"ems_fee": "",
"shipping_to": "",
"has_discount": "",
"video": "",
"is_virtual": "",
"sample_id": "",
"is_promotion": "",
"props_name": "0:0:颜色:瑞贝兔;0:1:颜色:洛洛小恐龙;0:2:颜色:悠悠兔;0:3:颜色:格林熊;0:4:颜色:尼尼狮;0:5:颜色:尤里狐;0:6:颜色:米尼猪;0:7:颜色:瑞克鸡;0:8:颜色:萌萌狗;0:9:颜色:瑞贝兔(plus版本);0:10:颜色:悠悠兔(plus版本);0:11:颜色:小恐龙(plus版本);0:12:颜色:尼尼狮(plus版本);0:13:颜色:太空舱学坐椅-瑞贝兔;0:14:颜色:太空舱学坐椅-咩咩羊;0:15:颜色:太空舱学坐椅-洛洛恐龙;0:16:颜色:布丁熊",
"prop_imgs": {
"prop_img": [
{
"properties": "0:0",
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01G9QIk21hqH44WtlCs_!!3978704328-0-cib.jpg"
},
{
"properties": "0:1",
"url": "https://cbu01.alicdn.com/img/ibank/13059989792_400746914.jpg"
},
{
"properties": "0:2",
"url": "https://cbu01.alicdn.com/img/ibank/13059992569_400746914.jpg"
},
{
"properties": "0:3",
"url": "https://cbu01.alicdn.com/img/ibank/12607397357_400746914.jpg"
},
{
"properties": "0:4",
"url": "https://cbu01.alicdn.com/img/ibank/12569956222_400746914.jpg"
},
{
"properties": "0:5",
"url": "https://cbu01.alicdn.com/img/ibank/12607388706_400746914.jpg"
},
{
"properties": "0:6",
"url": "https://cbu01.alicdn.com/img/ibank/17553257811_400746914.jpg"
},
{
"properties": "0:7",
"url": "https://cbu01.alicdn.com/img/ibank/17482684149_400746914.jpg"
},
{
"properties": "0:8",
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01acYlgA1hqGs8uJd3J_!!3978704328-0-cib.jpg"
},
{
"properties": "0:9",
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01b8uIbO1hqH419LUhC_!!3978704328-0-cib.jpg"
},
{
"properties": "0:10",
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01kW3Wye1hqGwD7K65Y_!!3978704328-0-cib.jpg"
},
{
"properties": "0:11",
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01rZ0GoO1hqGwEsvJKh_!!3978704328-0-cib.jpg"
},
{
"properties": "0:12",
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01q1RaO91hqGxDRk1Tu_!!3978704328-0-cib.jpg"
},
{
"properties": "0:13",
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01xD8Ejo1hqH3dLoFjb_!!3978704328-0-cib.jpg"
},
{
"properties": "0:14",
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01YhhIRL1hqH3lgzj4p_!!3978704328-0-cib.jpg"
},
{
"properties": "0:15",
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01ZwO17Q1hqH3jk6ZYi_!!3978704328-0-cib.jpg"
},
{
"properties": "0:16",
"url": "https://cbu01.alicdn.com/img/ibank/13059998398_400746914.jpg"
}
]
},
"property_alias": "0:0:瑞贝兔;0:1:洛洛小恐龙;0:2:悠悠兔;0:3:格林熊;0:4:尼尼狮;0:5:尤里狐;0:6:米尼猪;0:7:瑞克鸡;0:8:萌萌狗;0:9:瑞贝兔(plus版本);0:10:悠悠兔(plus版本);0:11:小恐龙(plus版本);0:12:尼尼狮(plus版本);0:13:太空舱学坐椅-瑞贝兔;0:14:太空舱学坐椅-咩咩羊;0:15:太空舱学坐椅-洛洛恐龙;0:16:布丁熊",
"props": [
{
"name": "货号",
"show": false,
"value": "456"
},
{
"name": "是否进口",
"show": false,
"value": "否"
},
{
"name": "产地",
"show": false,
"value": "浙江"
},
{
"name": "货源类别",
"show": false,
"value": "现货"
},
{
"name": "品牌",
"show": false,
"value": "其他"
},
{
"name": "材质",
"show": false,
"value": "海绵"
},
{
"name": "适用年龄",
"show": false,
"value": "6个月以上"
},
{
"name": "颜色",
"show": false,
"value": "瑞贝兔,洛洛小恐龙,悠悠兔,布丁熊,格林熊,尼尼狮,尤里狐,米尼猪,瑞克鸡,萌萌狗,瑞贝兔(plus版本),悠悠兔(plus版本),小恐龙(plus版本),尼尼狮(plus版本),太空舱学坐椅-瑞贝兔,太空舱学坐椅-咩咩羊,太空舱学坐椅-洛洛恐龙"
},
{
"name": "是否跨境出口专供货源",
"show": false,
"value": "否"
}
],
"total_sold": null,
"skus": {
"sku": [
{
"price": "314.00",
"total_price": 0,
"sales": "36",
"properties": "0:0",
"properties_name": "0:0:颜色:瑞贝兔",
"quantity": "4964",
"sku_id": "5140692509386",
"spec_id": "434b4733c0ab80c764568460ca461626"
},
{
"price": "314.00",
"total_price": 0,
"sales": "17868",
"properties": "0:1",
"properties_name": "0:1:颜色:洛洛小恐龙",
"quantity": "4446",
"sku_id": "3970787466016",
"spec_id": "2347ff7768ce5b080a1bfb9e9c04c5f0"
},
{
"price": "314.00",
"total_price": 0,
"sales": "15029",
"properties": "0:2",
"properties_name": "0:2:颜色:悠悠兔",
"quantity": "4559",
"sku_id": "3970787466017",
"spec_id": "f17293c355d13c469747b05f84578fb4"
},
{
"price": "314.00",
"total_price": 0,
"sales": "1119",
"properties": "0:3",
"properties_name": "0:3:颜色:格林熊",
"quantity": "2026",
"sku_id": "4260268916684",
"spec_id": "709090a0f521494834522ddee4d90172"
},
{
"price": "314.00",
"total_price": 0,
"sales": "11923",
"properties": "0:4",
"properties_name": "0:4:颜色:尼尼狮",
"quantity": "3964",
"sku_id": "4260268916685",
"spec_id": "8825ca0828a126abd1beee99c722e0c5"
},
{
"price": "314.00",
"total_price": 0,
"sales": "2792",
"properties": "0:5",
"properties_name": "0:5:颜色:尤里狐",
"quantity": "1590",
"sku_id": "4260268916683",
"spec_id": "63d5ae8ea486f5bfc25f20621b847f21"
},
{
"price": "314.00",
"total_price": 0,
"sales": "1248",
"properties": "0:6",
"properties_name": "0:6:颜色:米尼猪",
"quantity": "2658",
"sku_id": "4397558813893",
"spec_id": "0d2ba15de131ae9c857d8212c6ab907d"
},
{
"price": "314.00",
"total_price": 0,
"sales": "1051",
"properties": "0:7",
"properties_name": "0:7:颜色:瑞克鸡",
"quantity": "1855",
"sku_id": "4397558813894",
"spec_id": "6cad2b6d2dec24b943e40e14eaab7cbf"
},
{
"price": "314.00",
"total_price": 0,
"sales": "1102",
"properties": "0:8",
"properties_name": "0:8:颜色:萌萌狗",
"quantity": "1770",
"sku_id": "4539361301915",
"spec_id": "d86229162d0a1ad8ed270438e757a9e9"
},
{
"price": "369.00",
"total_price": 0,
"sales": "21",
"properties": "0:9",
"properties_name": "0:9:颜色:瑞贝兔(plus版本)",
"quantity": "7378",
"sku_id": "5140692509387",
"spec_id": "bdfbf7a4d5ab04790a39d4f382c6abcb"
},
{
"price": "369.00",
"total_price": 0,
"sales": "1812",
"properties": "0:10",
"properties_name": "0:10:颜色:悠悠兔(plus版本)",
"quantity": "7659",
"sku_id": "4863778116683",
"spec_id": "a058aa1227b1a31768b42dff22740b10"
},
{
"price": "369.00",
"total_price": 0,
"sales": "2358",
"properties": "0:11",
"properties_name": "0:11:颜色:小恐龙(plus版本)",
"quantity": "7523",
"sku_id": "4863778116682",
"spec_id": "10f340a8112adc31bf9b58378bb5e0dc"
},
{
"price": "369.00",
"total_price": 0,
"sales": "2981",
"properties": "0:12",
"properties_name": "0:12:颜色:尼尼狮(plus版本)",
"quantity": "7225",
"sku_id": "4891683965546",
"spec_id": "57b7ed3fdd875bf2befc0b0849614b43"
},
{
"price": "293.00",
"total_price": 0,
"sales": "4",
"properties": "0:13",
"properties_name": "0:13:颜色:太空舱学坐椅-瑞贝兔",
"quantity": "7476",
"sku_id": "5296477114081",
"spec_id": "b07b4b9069d468c59c71b422634be520"
},
{
"price": "293.00",
"total_price": 0,
"sales": "2",
"properties": "0:14",
"properties_name": "0:14:颜色:太空舱学坐椅-咩咩羊",
"quantity": "7478",
"sku_id": "5296477114080",
"spec_id": "a21dc0787f67b01775724f77b3845560"
},
{
"price": "293.00",
"total_price": 0,
"sales": "2",
"properties": "0:15",
"properties_name": "0:15:颜色:太空舱学坐椅-洛洛恐龙",
"quantity": "7478",
"sku_id": "5296477114079",
"spec_id": "57eca27c6bd2886a29a663d2815c3e2c"
},
{
"price": "314.00",
"total_price": 0,
"sales": "729",
"properties": "0:16",
"properties_name": "0:16:颜色:布丁熊",
"quantity": "0",
"sku_id": "3970787466018",
"spec_id": "bddcc92ced7a34224da5e1d288add79c"
}
]
},
"seller_id": "3978704328",
"sales": 4100,
"shop_id": "3978704328",
"props_list": {
"0:0": "颜色:瑞贝兔",
"0:1": "颜色:洛洛小恐龙",
"0:2": "颜色:悠悠兔",
"0:3": "颜色:格林熊",
"0:4": "颜色:尼尼狮",
"0:5": "颜色:尤里狐",
"0:6": "颜色:米尼猪",
"0:7": "颜色:瑞克鸡",
"0:8": "颜色:萌萌狗",
"0:9": "颜色:瑞贝兔(plus版本)",
"0:10": "颜色:悠悠兔(plus版本)",
"0:11": "颜色:小恐龙(plus版本)",
"0:12": "颜色:尼尼狮(plus版本)",
"0:13": "颜色:太空舱学坐椅-瑞贝兔",
"0:14": "颜色:太空舱学坐椅-咩咩羊",
"0:15": "颜色:太空舱学坐椅-洛洛恐龙",
"0:16": "颜色:布丁熊"
},
"seller_info": {
"nick": "安吉曼龙家居用品有限公司",
"user_num_id": "3978704328",
"sid": "b2b-39787043287ae07",
"title": "浙江曼龙家居用品有限公司",
"zhuy": "https://winport.m.1688.com/page/index.html?memberId=b2b-39787043287ae07",
"shop_name": "安吉曼龙家居用品有限公司"
},
"tmall": "false",
"error": "",
"warning": "",
"url_log": [],
"unit": null,
"is_support_mix": "true",
"mix_amount": "1",
"mix_begin": "0",
"mix_number": "2147483647",
"scale": "",
"sellUnit": "个",
"props_img": {
"0:0": "https://cbu01.alicdn.com/img/ibank/O1CN01G9QIk21hqH44WtlCs_!!3978704328-0-cib.jpg",
"0:1": "https://cbu01.alicdn.com/img/ibank/13059989792_400746914.jpg",
"0:2": "https://cbu01.alicdn.com/img/ibank/13059992569_400746914.jpg",
"0:3": "https://cbu01.alicdn.com/img/ibank/12607397357_400746914.jpg",
"0:4": "https://cbu01.alicdn.com/img/ibank/12569956222_400746914.jpg",
"0:5": "https://cbu01.alicdn.com/img/ibank/12607388706_400746914.jpg",
"0:6": "https://cbu01.alicdn.com/img/ibank/17553257811_400746914.jpg",
"0:7": "https://cbu01.alicdn.com/img/ibank/17482684149_400746914.jpg",
"0:8": "https://cbu01.alicdn.com/img/ibank/O1CN01acYlgA1hqGs8uJd3J_!!3978704328-0-cib.jpg",
"0:9": "https://cbu01.alicdn.com/img/ibank/O1CN01b8uIbO1hqH419LUhC_!!3978704328-0-cib.jpg",
"0:10": "https://cbu01.alicdn.com/img/ibank/O1CN01kW3Wye1hqGwD7K65Y_!!3978704328-0-cib.jpg",
"0:11": "https://cbu01.alicdn.com/img/ibank/O1CN01rZ0GoO1hqGwEsvJKh_!!3978704328-0-cib.jpg",
"0:12": "https://cbu01.alicdn.com/img/ibank/O1CN01q1RaO91hqGxDRk1Tu_!!3978704328-0-cib.jpg",
"0:13": "https://cbu01.alicdn.com/img/ibank/O1CN01xD8Ejo1hqH3dLoFjb_!!3978704328-0-cib.jpg",
"0:14": "https://cbu01.alicdn.com/img/ibank/O1CN01YhhIRL1hqH3lgzj4p_!!3978704328-0-cib.jpg",
"0:15": "https://cbu01.alicdn.com/img/ibank/O1CN01ZwO17Q1hqH3jk6ZYi_!!3978704328-0-cib.jpg",
"0:16": "https://cbu01.alicdn.com/img/ibank/13059998398_400746914.jpg"
},
"sales_data": null,
"_ddf": "ti",
"sales_info": {
"seller_num": "",
"repeat_rate_purchase": "",
"per_capita_purchases": "",
"comment_num": "",
"comment_url": ""
},
"format_check": "ok",
"shop_item": [],
"relate_items": []
},
四、接口实现
为了实现上述接口,我们需要进行以下步骤:
- 在微信小程序后台开通自营商城,并获取到微信小程序ID和秘钥。
- 在1688平台上注册账号,并获取到API权限和秘钥。
- 使用第三方开发工具(如Postman)或者自行编写程序,调用1688往微信小程序自营商城铺货商品采集API接口。
- 在采集商品信息时,需要按照接口设计的要求传入查询参数和商品信息等数据。
- 在更新商品信息时,需要按照接口设计的要求传入待更新商品的ID和更新后的商品信息等数据。
- 在删除商品信息时,需要按照接口设计的要求传入待删除商品的ID。
- 根据接口返回的结果,判断操作是否成功。如果操作成功,则表示商品信息已经成功采集、更新或删除;如果操作失败,则需要进行错误处理和提示用户。