电商数据接口平台1688阿里巴巴获得搜索词推荐获取商品详情数据

1688.item_search_suggest-获得搜索词推荐

公共参数

请求地址: 注册请求接入调用key

名称 类型 必须 描述
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版本

请求参数

请求参数:q=女装

参数说明:q:搜索关键字

响应参数

Version: Date:

名称 类型 必须 示例值 描述

items

items[] 0 按关键字搜索商品

result

result[] 0 _女装% 夏季 详情数据

 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_search_suggest/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&q=女装";
		JSONObject json = getRequestFromUrl(url);
		System.out.println(json.toString());
	}

}

响应示例

{
	"items": {
		"result": [
			[
				"_女装% 2021新款春季"
			],
			[
				"_女装% 春秋"
			],
			[
				"_女装% 2021夏季新款"
			],
			[
				"_女装%外套"
			],
			[
				"_女装% 欧美"
			],
			[
				"_女装% 中老年"
			],
			[
				"_女装% 潮流"
			],
			[
				"_女装% 跨境"
			],
			[
				"_女装% 2021新款"
			],
			[
				"_女装% 时尚"
			]
		]
	},
	"secache": "11d2656d59b74f2c8ea26f48e8a00827",
	"secache_time": 1614929727,
	"secache_date": "2021-03-05 15:35:27",
	"translate_status": "",
	"translate_time": 0,
	"language": {
		"default_lang": "cn",
		"current_lang": "cn"
	},
	"error": "",
	"reason": "",
	"error_code": "0000",
	"cache": 0,
	"api_info": "today:30 max:10000",
	"execution_time": 0.15,
	"server_time": "Beijing/2021-03-05 15:35:27",
	"client_ip": "106.6.39.197",
	"call_args": {
		"q": "女装"
	},
	"api_type": "1688",
	"translate_language": "zh-CN",
	"translate_engine": "google_cn",
	"server_memory": "3.53MB",
	"request_id": "4.6041df3f32028"
}

你可能感兴趣的:(电商平台,API接口,经验分享,java,spring,开发语言,大数据,php,数据库)