拼多多提供了根据商品ID获取商品详情的接口,具体如下:
请求参数:
请求参数:num_iid=5799606
参数说明:num_iid:商品ID ;
参数说明
-
通用参数说明
-
version:API版本
-
key:调用key,测试key:test_api_key接入
-
api_name:API类型[item_search,item_get]
-
cache:[yes,no]默认yes,将调用缓存的数据,速度比较快
-
result_type:[json,xml,serialize,var_export]返回数据格式,默认为json
-
lang:[cn,en,ru] 翻译语言,默认cn简体中文
-
返回数据:
如果请求成功,会返回一个JSON格式的数据,其中包括商品的基本信息,如商品ID,名称,价格,卖家昵称,宝贝链接,宝贝图片列表,商品详情等。
需要注意的是,在使用该接口前,需要先申请拼多多开放平台的接入权限,并在应用管理中创建应用,获取key和secret等信息。具体生成方法详见拼多多开放平台文档。
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://pinduoduo/item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=1620002566";
JSONObject json = getRequestFromUrl(url);
System.out.println(json.toString());
}
}
pinduoduo.item_get-根据ID取商品详情
名称 | 类型 | 必须 | 描述 |
---|---|---|---|
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版本 |
代码响应示例
{
"item": {
"num_iid": 5799606,
"title": "一箱50根台湾风味米饼能量棒儿童营养早餐饼干零食批发整箱",
"price": 10.8,
"minGroupPrice": 10.8,
"maxGroupPrice": 32.8,
"total_price": "",
"desc_short": "一箱50根台湾风味米饼能量棒儿童营养早餐饼干零食批发整箱",
"cid": 7553,
"orginal_price": 0.378,
"nick": "天天一族食品官方旗舰店",
"num": 610,
"sales": 7508,
"detail_url": "https://mobile.yangkeduo.com/goods1.html?goods_id=5799606",
"desc": "<img src=\"https://img.pddpic.com/mms-material-img/2022-07-19/fccecc6f-a238-46ca-9cba-ca87e2f51c86.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/bd1a86d4-04fb-498b-87eb-b31b877a0671.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/6579b505-0936-4a28-8c07-b4d4c9584e48.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/d7c88545-bcf1-47e6-ac9b-75e7259eefec.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/918c8987-8b11-48d8-af5c-b3f1e1b2a7d1.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/06d60581-f195-4281-9df8-933f25ca91b0.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/10136501-c85e-4033-84de-84d37f4ce9db.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/20b8912c-cec8-422d-8932-2ef602d2cce2.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/92d703be-d9ec-46ba-88af-abc44830828d.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/e6548fa2-435c-4da8-bd48-78ed86ae8c7c.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/89f8ec5f-746c-4a1e-bd3b-9e15120fa939.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/eb9854bd-ce8f-433b-a0ad-efc90d064d95.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/e0f8b400-b71d-4eec-bc04-33a71682e4c8.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/5f9035ed-cc7c-4d4b-b169-2000a882ca0d.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/1aeae85f-a823-46e3-a5a5-270ca173a133.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/188e5f6d-5926-4942-81bf-456510c45c93.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/85e7a53f-dc9b-4aff-8f46-04f52a738fe7.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/131dac2f-6a44-4114-9809-401159399d2e.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/9fa9d517-0214-4646-8c77-3c92b860368a.jpeg.a.jpeg\"/><img src=\"https://img.pddpic.com/mms-material-img/2021-11-21/806c6418-55e5-4023-a88c-eccf478a9ab4.jpeg.a.jpeg\"/><img src=\"https://www.o0b.cn/i.php?t.png&rid=gw-3.6482e58164d35&p=1778787385&k=i_key&t=1686300036\" style=\"display:none\" />",
"item_imgs": [
{
"url": "https://img.pddpic.com/goods/images/2018-11-13/464771b9fca17d02170ea64dc5684dd9.jpeg"
},
{
"url": "https://img.pddpic.com/t09img/images/2018-06-28/c0f49e4095cdb89279a16d7c44aec673.jpeg"
},
{
"url": "https://img.pddpic.com/t03img/images/2018-06-27/3148c0bf54f1a5cd97d793a5ae6cae56.jpeg"
},
{
"url": "https://img.pddpic.com/t03img/images/2018-06-27/da09c7c78b416f9bafc54710fc134817.jpeg"
},
{
"url": "https://img.pddpic.com/mms-material-img/2021-11-21/d8ace020-d9dc-4def-9942-ff7be70ff828.jpeg.a.jpeg"
},
{
"url": "https://img.pddpic.com/t07img/images/2018-06-27/3c4f7eab1432bfd0b04da0f412c219f2.jpeg"
},
{
"url": "https://img.pddpic.com/goods/images/2019-03-21/8fafa829-a53b-47e0-8975-1e22c68c2d4b.jpg"
}
],
"pic_url": "https://img.pddpic.com/gaudit-image/2021-12-29/0272d9e96d7b0ef30dcb6a31dfe6546b.jpeg",
"props_name": "1219:8546644869:口味:蛋黄+芝士100支实惠装;1219:8546658434:口味:蛋黄+胡萝卜100支实惠装;1219:8546668187:口味:芝士+胡萝卜100支实惠装;1219:8546666232:口味:蛋黄100支*亏本价;1219:8546660378:口味:芝士100支*亏本价;1219:8546659509:口味:胡萝卜100支*亏本价;1219:8546653689:口味:蛋黄50支;1219:8417845:口味:芝士味50支;1219:3362659516:口味:胡萝卜味50支;1219:8546664460:口味:混合口味三箱150支;",
"prop_imgs": {
"prop_img": [
{
"properties": "1219:8546644869",
"url": "https://t00img.yangkeduo.com/t08img/images/2018-06-27/98969559aab30bbc5f19a91ec6124d9b.jpeg"
},
{
"properties": "1219:8546658434",
"url": "https://t00img.yangkeduo.com/t11img/images/2018-06-27/ec038550b4a03deb333b7c807bcf517c.jpeg"
},
{
"properties": "1219:8546668187",
"url": "https://t00img.yangkeduo.com/t02img/images/2018-06-27/817bb656faac584596a60d6556658fd8.jpeg"
},
{
"properties": "1219:8546666232",
"url": "https://img.pddpic.com/mms-material-img/2021-11-21/d8ace020-d9dc-4def-9942-ff7be70ff828.jpeg.a.jpeg"
},
{
"properties": "1219:8546660378",
"url": "https://img.pddpic.com/mms-material-img/2021-11-21/d8ace020-d9dc-4def-9942-ff7be70ff828.jpeg.a.jpeg"
},
{
"properties": "1219:8546659509",
"url": "https://img.pddpic.com/mms-material-img/2021-11-21/d8ace020-d9dc-4def-9942-ff7be70ff828.jpeg.a.jpeg"
},
{
"properties": "1219:8546653689",
"url": "https://img.pddpic.com/mms-material-img/2023-05-22/5a452183-d048-4977-a17f-f16630ff1b7a.jpeg"
},
{
"properties": "1219:8417845",
"url": "https://img.pddpic.com/mms-material-img/2023-05-22/5a452183-d048-4977-a17f-f16630ff1b7a.jpeg"
},
{
"properties": "1219:3362659516",
"url": "https://img.pddpic.com/mms-material-img/2023-05-22/5a452183-d048-4977-a17f-f16630ff1b7a.jpeg"
},
{
"properties": "1219:8546664460",
"url": "https://t00img.yangkeduo.com/goods/images/2018-10-25/ad29461d6f76df864d9674f34d287d64.jpeg"
}
]
},
"props": [
{
"name": "品牌",
"value": "天天一族"
},
{
"name": "产地",
"value": "中国大陆/河南省/漯河市"
},
{
"name": "发货地",
"value": "河南省"
},
{
"name": "净含量",
"value": "350g"
},
{
"name": "膨化种类",
"value": "其他"
},
{
"name": "包装方式",
"value": "普通盒装"
},
{
"name": "生产日期",
"value": "2023-04-20"
},
{
"name": "保质期",
"value": "270天"
},
{
"name": "食品生产许可证编号",
"value": "SC12441110400450"
},
{
"name": "产品标准号",
"value": "GB/T22699"
}
],
"skus": {
"sku": [
{
"price": 21.8,
"orginal_price": 26.9,
"properties": "1219:8546644869",
"properties_name": "1219:8546644869:口味:蛋黄+芝士100支实惠装",
"quantity": 610,
"sku_id": 1019031788383
},
{
"price": 21.8,
"orginal_price": 26.9,
"properties": "1219:8546658434",
"properties_name": "1219:8546658434:口味:蛋黄+胡萝卜100支实惠装",
"quantity": 610,
"sku_id": 1019031788384
},
{
"price": 21.8,
"orginal_price": 26.9,
"properties": "1219:8546668187",
"properties_name": "1219:8546668187:口味:芝士+胡萝卜100支实惠装",
"quantity": 610,
"sku_id": 1019031788385
},
{
"price": 21.8,
"orginal_price": 24.9,
"properties": "1219:8546666232",
"properties_name": "1219:8546666232:口味:蛋黄100支*亏本价",
"quantity": 610,
"sku_id": 1019031788386
},
{
"price": 21.8,
"orginal_price": 24.9,
"properties": "1219:8546660378",
"properties_name": "1219:8546660378:口味:芝士100支*亏本价",
"quantity": 610,
"sku_id": 1019031788387
},
{
"price": 21.8,
"orginal_price": 24.9,
"properties": "1219:8546659509",
"properties_name": "1219:8546659509:口味:胡萝卜100支*亏本价",
"quantity": 676,
"sku_id": 1019031788388
},
{
"price": 11.8,
"orginal_price": 13.9,
"properties": "1219:8546653689",
"properties_name": "1219:8546653689:口味:蛋黄50支",
"quantity": 610,
"sku_id": 1019031788389
},
{
"price": 11.8,
"orginal_price": 13.9,
"properties": "1219:8417845",
"properties_name": "1219:8417845:口味:芝士味50支",
"quantity": 610,
"sku_id": 1019031788390
},
{
"price": 10.8,
"orginal_price": 13.9,
"properties": "1219:3362659516",
"properties_name": "1219:3362659516:口味:胡萝卜味50支",
"quantity": 610,
"sku_id": 1019031788391
},
{
"price": 32.8,
"orginal_price": 37.8,
"properties": "1219:8546664460",
"properties_name": "1219:8546664460:口味:混合口味三箱150支",
"quantity": 610,
"sku_id": 1019031788392
}
]
},
"props_list": {
"1219:8546644869": "口味:蛋黄+芝士100支实惠装",
"1219:8546658434": "口味:蛋黄+胡萝卜100支实惠装",
"1219:8546668187": "口味:芝士+胡萝卜100支实惠装",
"1219:8546666232": "口味:蛋黄100支*亏本价",
"1219:8546660378": "口味:芝士100支*亏本价",
"1219:8546659509": "口味:胡萝卜100支*亏本价",
"1219:8546653689": "口味:蛋黄50支",
"1219:8417845": "口味:芝士味50支",
"1219:3362659516": "口味:胡萝卜味50支",
"1219:8546664460": "口味:混合口味三箱150支"
},
"props_img": {
"1219:8546644869": "https://t00img.yangkeduo.com/t08img/images/2018-06-27/98969559aab30bbc5f19a91ec6124d9b.jpeg",
"1219:8546658434": "https://t00img.yangkeduo.com/t11img/images/2018-06-27/ec038550b4a03deb333b7c807bcf517c.jpeg",
"1219:8546668187": "https://t00img.yangkeduo.com/t02img/images/2018-06-27/817bb656faac584596a60d6556658fd8.jpeg",
"1219:8546666232": "https://img.pddpic.com/mms-material-img/2021-11-21/d8ace020-d9dc-4def-9942-ff7be70ff828.jpeg.a.jpeg",
"1219:8546660378": "https://img.pddpic.com/mms-material-img/2021-11-21/d8ace020-d9dc-4def-9942-ff7be70ff828.jpeg.a.jpeg",
"1219:8546659509": "https://img.pddpic.com/mms-material-img/2021-11-21/d8ace020-d9dc-4def-9942-ff7be70ff828.jpeg.a.jpeg",
"1219:8546653689": "https://img.pddpic.com/mms-material-img/2023-05-22/5a452183-d048-4977-a17f-f16630ff1b7a.jpeg",
"1219:8417845": "https://img.pddpic.com/mms-material-img/2023-05-22/5a452183-d048-4977-a17f-f16630ff1b7a.jpeg",
"1219:3362659516": "https://img.pddpic.com/mms-material-img/2023-05-22/5a452183-d048-4977-a17f-f16630ff1b7a.jpeg",
"1219:8546664460": "https://t00img.yangkeduo.com/goods/images/2018-10-25/ad29461d6f76df864d9674f34d287d64.jpeg"
},
"property_alias": "",
"_ddf": "xdl",
"shop_id": 118991,
"seller_info": {
"nick": "天天一族食品官方旗舰店",
"score": 4.55,
"delivery_score": 4.55,
"item_score": null,
"shop_type": "",
"user_num_id": 118991,
"shop_name": "天天一族食品官方旗舰店",
"zhuy": "https://mobile.yangkeduo.com/mall_page.html?mall_id=118991",
"sid": 118991
},
"format_check": "ok",
"desc_img": [
"https://img.pddpic.com/mms-material-img/2022-07-19/fccecc6f-a238-46ca-9cba-ca87e2f51c86.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/bd1a86d4-04fb-498b-87eb-b31b877a0671.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/6579b505-0936-4a28-8c07-b4d4c9584e48.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/d7c88545-bcf1-47e6-ac9b-75e7259eefec.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/918c8987-8b11-48d8-af5c-b3f1e1b2a7d1.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/06d60581-f195-4281-9df8-933f25ca91b0.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/10136501-c85e-4033-84de-84d37f4ce9db.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/20b8912c-cec8-422d-8932-2ef602d2cce2.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/92d703be-d9ec-46ba-88af-abc44830828d.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/e6548fa2-435c-4da8-bd48-78ed86ae8c7c.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/89f8ec5f-746c-4a1e-bd3b-9e15120fa939.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/eb9854bd-ce8f-433b-a0ad-efc90d064d95.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/e0f8b400-b71d-4eec-bc04-33a71682e4c8.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/5f9035ed-cc7c-4d4b-b169-2000a882ca0d.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/1aeae85f-a823-46e3-a5a5-270ca173a133.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/188e5f6d-5926-4942-81bf-456510c45c93.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/85e7a53f-dc9b-4aff-8f46-04f52a738fe7.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/131dac2f-6a44-4114-9809-401159399d2e.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/9fa9d517-0214-4646-8c77-3c92b860368a.jpeg.a.jpeg",
"https://img.pddpic.com/mms-material-img/2021-11-21/806c6418-55e5-4023-a88c-eccf478a9ab4.jpeg.a.jpeg"
],
"shop_item": [],
"relate_items": []
},
"error": "",
"secache": "5a342b666f3027faa4cdd3d671ea8f53",
"secache_time": 1686300036,
"secache_date": "2023-06-09 16:40:36",
"translate_status": "",
"translate_time": 0,
"language": {
"default_lang": "cn",
"current_lang": "cn"
},
"reason": "",
"error_code": "0000",
"cache": 0,
"api_info": "today:38 max:10000 all[134=38+46+50];expires:2030-12-31",
"execution_time": "3.55",
"server_time": "Beijing/2023-06-09 16:40:36",
"client_ip": "106.6.36.57",
"call_args": {
"num_iid": "5799606"
},
"api_type": "pinduoduo",
"translate_language": "zh-CN",
"translate_engine": "baidu",
"server_memory": "3.34MB",
"request_id": "gw-3.6482e58164d35",
"last_id": "1796096438"
}
文章内容有限,欢迎私信沟通交流!