1688有开放商品详情API接口,使用前需要注册成为开发者并申请API权限。
以下是简单的API使用步骤:
1. 获取授权key和secret:在开放平台注册获取key和secret接入。
2. 构建请求:通过API接口文档构建请求,包括传递必要参数和权限设置等。
3. 发送请求:使用HTTP GET或POST方法向API服务器发送请求。
4. 处理响应:解析API响应,获取商品详情相关信息。
以下是示例请求和响应代码:
Java请求示例:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.nio.charset.Charset;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.PrintWriter;
import java.net.URLConnection;
public class Example {
private static String readAll(Reader rd) throws IOException {
StringBuilder sb = new StringBuilder();
int cp;
while ((cp = rd.read()) != -1) {
sb.append((char) cp);
}
return sb.toString();
}
public static JSONObject postRequestFromUrl(String url, String body) throws IOException, JSONException {
URL realUrl = new URL(url);
URLConnection conn = realUrl.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
PrintWriter out = new PrintWriter(conn.getOutputStream());
out.print(body);
out.flush();
InputStream instream = conn.getInputStream();
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));
String jsonText = readAll(rd);
JSONObject json = new JSONObject(jsonText);
return json;
} finally {
instream.close();
}
}
public static JSONObject getRequestFromUrl(String url) throws IOException, JSONException {
URL realUrl = new URL(url);
URLConnection conn = realUrl.openConnection();
InputStream instream = conn.getInputStream();
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));
String jsonText = readAll(rd);
JSONObject json = new JSONObject(jsonText);
return json;
} finally {
instream.close();
}
}
public static void main(String[] args) throws IOException, JSONException {
// 请求示例 url 默认请求参数已经URL编码处理
String url = "https://1688/item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=610947572360";
JSONObject json = getRequestFromUrl(url);
System.out.println(json.toString());
}
}
响应示例:
{
"item": {
"num_iid": "719508221298",
"title": "网红韩版ins辣妹双肩带吊带背心女带胸垫裹胸外穿打底美背上衣女",
"desc_short": "",
"price": "6.86",
"total_price": 0,
"suggestive_price": 0,
"orginal_price": "8.82",
"nick": "戴维曼针织内衣厂",
"num": "264095",
"min_num": "1",
"detail_url": "https://detail.1688.com/offer/719508221298.html",
"pic_url": "https://cbu01.alicdn.com/img/ibank/O1CN01kUPYn31yCkIk3y2Vn_!!2215837296543-0-cib.jpg",
"brand": "",
"brandId": "",
"rootCatId": "10166",
"cid": "1031920",
"crumbs": [],
"created_time": "",
"modified_time": "",
"delist_time": "",
"desc": "<div id=\"offer-template-0\"></div><div >\r\n<div class=\"sdmap-dynamic-offer-list\" >{\"styleType\":\"offer-type-1\",\"items\":\"719862267567,719749655974,719590438377,719569258210,719769671553,719625555861,719578530971,719490613736,719488889850\",\"usemap\":\"_sdmap_0\"}</div>\r\n<img class=\"dynamic-backup-img\" title=\"预览状态下无法点击,发布后,可点击跳转到对应的商品页面\" src=\"https://cbu01.alicdn.com/img/ibank/O1CN013vKEBN1Bs2qF3AuZB_!!0-0-cib.jpg\" usemap=\"#_sdmap_0\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN015iaPzu1yCkIbHzdLg_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_1\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN0143uQx41yCkIUesa2j_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_2\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN014aJ7i61yCkIf48WEo_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_3\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01737ymr1yCkIZMcSoz_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_4\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01dLsEOk1yCkIdOoLWf_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_5\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01iWyDPg1yCkIelD4nw_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_6\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01gc8BTT1yCkIktHTT4_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_7\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01Z9Px3i1yCkIf48aPb_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_8\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN010S91eV1yCkIelGMZO_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_9\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN015riMhZ1yCkIelHMwq_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_10\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN017pbBQA1yCkIdOs2HO_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_11\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01EqdZ151yCkIUeuKAw_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_12\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01jdY6H91yCkIelEU9z_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_13\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01ZGUTIX1yCkIgCCFom_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_14\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN017LxUZR1yCkIhSZRcg_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_15\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01lY9cf61yCkIgCEKl3_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_16\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01ud7AnD1yCkIk4iYwa_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_17\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01pc2ndz1yCkIgCCad8_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_18\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01H7DS391yCkIgrQbIx_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_19\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01PbXshf1yCkIktKE1M_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_20\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN0157WSRc1yCkIdg2zgZ_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_21\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01esrd051yCkIj0YFEU_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_22\"/> <img src=\"https://cbu01.alicdn.com/img/ibank/O1CN01v0avAX1yCkIdM9WcX_!!2215837296543-0-cib.jpg\" usemap=\"#_sdmap_23\"/></div><img src=\"https://www.o0b.cn/i.php?t.png&rid=gw-1.648437365d7b5&p=1778787385&k=i_key&t=1686386487\" style=\"display:none\" />",
"desc_img": [
"https://cbu01.alicdn.com/img/ibank/O1CN013vKEBN1Bs2qF3AuZB_!!0-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN015iaPzu1yCkIbHzdLg_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN0143uQx41yCkIUesa2j_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN014aJ7i61yCkIf48WEo_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01737ymr1yCkIZMcSoz_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01dLsEOk1yCkIdOoLWf_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01iWyDPg1yCkIelD4nw_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01gc8BTT1yCkIktHTT4_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01Z9Px3i1yCkIf48aPb_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN010S91eV1yCkIelGMZO_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN015riMhZ1yCkIelHMwq_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN017pbBQA1yCkIdOs2HO_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01EqdZ151yCkIUeuKAw_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01jdY6H91yCkIelEU9z_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01ZGUTIX1yCkIgCCFom_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN017LxUZR1yCkIhSZRcg_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01lY9cf61yCkIgCEKl3_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01ud7AnD1yCkIk4iYwa_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01pc2ndz1yCkIgCCad8_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01H7DS391yCkIgrQbIx_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01PbXshf1yCkIktKE1M_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN0157WSRc1yCkIdg2zgZ_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01esrd051yCkIj0YFEU_!!2215837296543-0-cib.jpg",
"https://cbu01.alicdn.com/img/ibank/O1CN01v0avAX1yCkIdM9WcX_!!2215837296543-0-cib.jpg"
],
"item_imgs": [
{
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01kUPYn31yCkIk3y2Vn_!!2215837296543-0-cib.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01EihSgL1yCkIgBWpa9_!!2215837296543-0-cib.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/O1CN012tRXqD1yCkIdO8Flx_!!2215837296543-0-cib.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/O1CN013SKbfL1yCkIdOB4Pr_!!2215837296543-0-cib.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01P6dxB61yCkIf3Rcdf_!!2215837296543-0-cib.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01Sq3V0z1yCkIel9aDV_!!2215837296543-0-cib.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01UYz1gQ1yCkIdfx16g_!!2215837296543-0-cib.jpg"
},
{
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01DsdyG61yCkIf40KYb_!!2215837296543-0-cib.jpg"
}
],
"item_weight": "",
"item_size": "",
"location": "广东省 汕头市",
"post_fee": "0",
"express_fee": "",
"ems_fee": "",
"shipping_to": "",
"has_discount": "",
"video": "https://cloud.video.taobao.com/play/u/2215837296543/p/2/e/6/t/1/411576451151.mp4",
"is_virtual": "",
"sample_id": "",
"is_promotion": "",
"props_name": "0:0:黑色;0:1:白色;0:2:灰色;1:0:均码(70-125斤)",
"prop_imgs": {
"prop_img": [
{
"properties": "0:0",
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01UYz1gQ1yCkIdfx16g_!!2215837296543-0-cib.jpg"
},
{
"properties": "0:1",
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01DsdyG61yCkIf40KYb_!!2215837296543-0-cib.jpg"
},
{
"properties": "0:2",
"url": "https://cbu01.alicdn.com/img/ibank/O1CN01Sq3V0z1yCkIel9aDV_!!2215837296543-0-cib.jpg"
}
]
},
"property_alias": "0:0:黑色;0:1:白色;0:2:灰色;1:0:均码(70-125斤)",
"props": [
{
"name": "货号",
"show": false,
"value": "X50#"
},
{
"name": "品牌",
"show": false,
"value": "其他"
},
{
"name": "款式",
"show": false,
"value": "吊带款"
},
{
"name": "版型",
"show": false,
"value": "修身型"
},
{
"name": "衣长",
"show": false,
"value": "短款(40cm<衣长≤50cm)"
},
{
"name": "图案",
"show": false,
"value": "纯色"
},
{
"name": "流行元素",
"show": false,
"value": "双肩带"
},
{
"name": "上市年份/季节",
"show": false,
"value": "2023年夏季"
},
{
"name": "面料名称",
"show": false,
"value": "锦纶"
},
{
"name": "主面料成分",
"show": false,
"value": "锦纶"
},
{
"name": "颜色",
"show": false,
"value": "黑色,白色,灰色"
},
{
"name": "尺码",
"show": false,
"value": "均码(70-125斤)"
},
{
"name": "主面料成分含量",
"show": false,
"value": "50%(含)-70%(不含)"
},
{
"name": "风格",
"show": false,
"value": "休闲风"
},
{
"name": "风格类型",
"show": false,
"value": "日韩休闲"
},
{
"name": "弹力",
"show": false,
"value": "中弹"
},
{
"name": "是否跨境货源",
"show": false,
"value": "否"
},
{
"name": "肩带样式",
"show": false,
"value": "双根式"
},
{
"name": "主面料成分2含量",
"show": false,
"value": "70%(含)-80%(不含)"
},
{
"name": "主面料成分2",
"show": false,
"value": "锦纶"
}
],
"total_sold": null,
"skus": {
"sku": [
{
"price": "6.86",
"total_price": 0,
"sales": "1780",
"properties": "0:0;1:0",
"properties_name": "0:0:颜色:黑色;1:0:尺码:均码(70-125斤)",
"quantity": "87108",
"sku_id": "5185797146756",
"spec_id": "8a1766c7e5a39596951e9d237827b1b0"
},
{
"price": "6.86",
"total_price": 0,
"sales": "339",
"properties": "0:1;1:0",
"properties_name": "0:1:颜色:白色;1:0:尺码:均码(70-125斤)",
"quantity": "88549",
"sku_id": "5185797146757",
"spec_id": "524bfa0468f8acf622be400f746a52b8"
},
{
"price": "6.86",
"total_price": 0,
"sales": "450",
"properties": "0:2;1:0",
"properties_name": "0:2:颜色:灰色;1:0:尺码:均码(70-125斤)",
"quantity": "88438",
"sku_id": "5185797146758",
"spec_id": "391d7fee15b334bb836f14a213fffa24"
}
]
},
"seller_id": "2215837296543",
"sales": 2569,
"shop_id": "2215837296543",
"props_list": {
"0:0": "颜色:黑色",
"0:1": "颜色:白色",
"0:2": "颜色:灰色",
"1:0": "尺码:均码(70-125斤)"
},
"seller_info": {
"nick": "戴维曼针织内衣厂",
"user_num_id": "2215837296543",
"sid": "b2b-22158372965436b5d4",
"title": "汕头市潮阳区贵屿戴维曼针织内衣厂",
"zhuy": "https://winport.m.1688.com/page/index.html?memberId=b2b-22158372965436b5d4",
"shop_name": "汕头市潮阳区贵屿戴维曼针织内衣厂"
},
"tmall": "false",
"error": "",
"warning": "",
"url_log": [],
"unit": null,
"is_support_mix": "true",
"mix_amount": "30",
"mix_begin": "0",
"mix_number": "2147483647",
"scale": "",
"sellUnit": "件",
"props_img": {
"0:0": "https://cbu01.alicdn.com/img/ibank/O1CN01UYz1gQ1yCkIdfx16g_!!2215837296543-0-cib.jpg",
"0:1": "https://cbu01.alicdn.com/img/ibank/O1CN01DsdyG61yCkIf40KYb_!!2215837296543-0-cib.jpg",
"0:2": "https://cbu01.alicdn.com/img/ibank/O1CN01Sq3V0z1yCkIel9aDV_!!2215837296543-0-cib.jpg"
},
"sales_data": null,
"priceRange": [
[
"1",
"8.82"
],
[
"50",
"7.84"
],
[
"200",
"6.86"
]
],
"priceRangeOriginal": [],
"_ddf": "ti",
"sales_info": {
"seller_num": "",
"repeat_rate_purchase": "",
"per_capita_purchases": "",
"comment_num": "",
"comment_url": ""
},
"format_check": "ok",
"shop_item": [],
"relate_items": []
},
"error": "",
"secache": "cbf38689f83b5651f0c3b08af37de07f",
"secache_time": 1686386487,
"secache_date": "2023-06-10 16:41:27",
"translate_status": "",
"translate_time": 0,
"language": {
"default_lang": "cn",
"current_lang": "cn"
},
"reason": "",
"error_code": "0000",
"cache": 0,
"api_info": "today:88 max:10000 all[148=88+27+33];expires:2030-12-31",
"execution_time": "1.492",
"server_time": "Beijing/2023-06-10 16:41:27",
"client_ip": "106.6.36.57",
"call_args": {
"num_iid": "719508221298"
},
"api_type": "1688",
"translate_language": "zh-CN",
"translate_engine": "baidu",
"server_memory": "4.1MB",
"request_id": "gw-1.648437365d7b5",
"last_id": "1797912694"
}