拼多多搜尋詞統計 API介面操作展示說明

API測試Cris發表於2023-04-19

透過次介面 item_search_data可以獲取搜尋詞統計,同時瞭解到該店鋪的(num_iid商品ID、title商品標題、price價格、orginal_price原價、nick賣家暱稱、num庫存、sales銷量、detail_url寶貝連結、desc商品備註、item_imgs寶貝圖片列表、pic_url寶貝圖片、props_name商品屬性名、prop_imgs商品屬性圖片列、props商品詳情、skus商品規格資訊、props_list商品屬性、props_img屬性圖片、property_alias商品屬性別名、seller_info賣家資訊等等)

接下來我會展示該介面的操作及說明


公共引數


名稱 型別 必須 描述

key String 呼叫key(必須以GET方式拼接在URL中)

secret String 呼叫金鑰(介面-v;18870288846

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版本

請求引數


請求引數:q=女裝


引數說明:q:搜尋關鍵字



響應引數


Version: Date:


名稱 型別 必須 示例值 描述

items


items[] 0 獲得搜尋詞推薦

keyword


Mix 0 女裝 搜尋詞

result


Mix 0 ["女裝2019新款潮"] 推薦搜尋詞列表

請求示例


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 = "/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&q=女裝";

JSONObject json = getRequestFromUrl(url);

System.out.println(json.toString());

}

 

}


響應示例


{

"items": {

"keyword": "女裝",

"result": [

[

"女裝2021新款潮"

],

[

"女裝摩托車"

],

[

"女裝三件套洋氣"

],

[

"女裝衛衣春秋"

],

[

"女裝套裝"

],

[

"女裝春裝"

],

[

"女裝小個子"

],

[

"女裝2021新款外套"

],

[

"女裝襯衫長袖洋氣"

],

[

"女裝羽絨服外套長款"

],

[

"女裝t恤新款時尚"

],

[

"女裝內褲"

],

[

"女裝上衣"

],

[

"女裝春秋裝"

],

[

"女裝衣服外套"

],

[

"女裝羽絨服"

],

[

"女裝睡衣"

],

[

"女裝運動套裝"

],

[

"女裝衛衣"

],

[

"女裝馬甲外套"

]

]

},

"secache": "11d2656d59b74f2c8ea26f48e8a00827",

"secache_time": 1615362713,

"secache_date": "2021-03-10 15:51:53",

"translate_status": "",

"translate_time": 0,

"language": {

"default_lang": "cn",

"current_lang": "cn"

},

"error": "",

"reason": "",

"error_code": "0000",

"cache": 0,

"api_info": "today:31 max:10000",

"execution_time": 0.098,

"server_time": "Beijing/2021-03-10 15:51:53",

"client_ip": "106.6.35.144",

"call_args": {

"q": "女裝"

},

"api_type": "pinduoduo",

"translate_language": "zh-CN",

"translate_engine": "baidu",

"server_memory": "2.85MB",

"request_id": "gw-1.60487a996c711"

}

文章內容有限,歡迎私信溝通交流

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70028219/viewspace-2946841/,如需轉載,請註明出處,否則將追究法律責任。

相關文章