搜索词推荐的作用
1.可以精准把控流量
2.可以测试产品款式测试产品图片
3.提升类目在平台的排名
4.提升销量,加速报名参加平台的活动
5.提升ROI,日常平销
item_search_suggest-获得搜索词推荐
公共参数
名称 | 类型 | 必须 | 描述 |
key | String | 是 | 调用key(必须以GET方式拼接在URL中) |
secret | String | 是 | 调用密钥(接口,-v-x;PNG_WNMN |
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新款潮"] | 推荐搜索词列表 |
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://-v-x;PNG_WNMN/?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"
}
异常示例
{
"error": "item-not-found",
"reason": "商品没找到",
"error_code": "2000",
"success": 0,
"cache": 0,
"api_info": "today:0 max:10000",
"execution_time": 0.081,
"server_time": "Beijing/2020-06-10 23:44:00",
"call_args": [],
"api_type": "taobao",
"request_id": "15ee0ffc041242"}
欢迎大家私信沟通交流!