Obtain Taobao product category details API, grab Taobao full product category API interface sharing (code display, parameter description)

Commodity classification skills

How to set up Taobao store classification? When we log in to the seller account, we see our products and want to classify the products. A good classification can help increase the exposure of the products. So before classifying the products, if you have no clue, the following points can give you a little help.

1. You can refer to the classification of some big brands, and then we can imitate the classification in our own Taobao store.

2. The options on the baby search page can be used as a reference for setting categories.

3. Select the appropriate number of categories for the category, within 10 is the best, not too many, otherwise it will be very messy.

API call example

Through the API interface, you can get all the categories of Taobao products, and you can also quickly grab the classification details of specific products. The following are examples of interface calls.

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://vx-15870092527.cn/taobao/cat_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&cid=16";
		JSONObject json = getRequestFromUrl(url);
		System.out.println(json.toString());
	}

}

Parameter Description

public parameters

name type must describe
key String yes Call key (must be spliced ​​in the URL in GET mode)
secret String yes call key
api_name String yes API interface name (included in the request address) [item_search, item_get, item_search_shop, etc.]
cache String no [yes, no] The default is yes, the cached data will be called, and the speed is relatively fast
result_type String no [json,jsonu,xml,serialize,var_export] returns the data format, the default is json, the content output by jsonu can be read directly in Chinese
lang String no [cn,en,ru] translation language, default cn Simplified Chinese
version String no API version

request parameters

Request parameter: cid=16

Parameter description: cid: commodity category ID, you can use cid=0 to get all first-level categories

response parameters

Version: Date:

name type must example value describe

info

Mix 0 {"cid": 16, "parent_cid": 0, "name": "其他女装", "is_parent": "true", "status": "normal", "sort_order": "0"}, Classified information

item

Mix 0 {"1624": "Professional wear/work clothes/school uniform", "50000852": "Middle-aged and elderly women's clothing", "50008906": "Tang suit/ethnic/stage costume", "50029581": "Maga", "50095935": " Faux leather jacket", "50099705": "Large size women's clothing", "50099718": "Wedding dress/dress/cheongsam"} subcategory id: subcategory name

Data description document entry 

 

Guess you like

Origin blog.csdn.net/Jernnifer_mao/article/details/130104829