栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > .Net

通过cid获取京东商品分类ID,京东商品分类API接口,京东商品分类详情接口,分类详情API接口,接口接入方案

.Net 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

通过cid获取京东商品分类ID,京东商品分类API接口,京东商品分类详情接口,分类详情API接口,接口接入方案

一、京东商品分类API接口参数说明:
1.通过cid获取京东商品分类ID,可以用cid=0来获得所有一级类目,可以获取到:商品分类ID,分类名
,父分类ID,根分类ID,子分类id:子分类名称等信息。
点击注册获取测试key和secret
2.请求参数:请求参数:cid=0
参数说明:cid:商品分类ID,可以用cid=0来获得所有一级类目
3.响应参数:
名称 类型 是否隐私 示例值 描述
id Int 54 商品分类ID
name String 服饰配件、饰品 分类名
pid String 0 父分类ID
root_id String 0 根分类ID
item Mix {“id”: 127464010,“name”: “帽子/头巾”,“pid”: “54”,“root_id”: 0,sub[]} 子分类id:子分类名称
二、请求示例:(CURL、PHP 、PHPsdk 、Java 、C# 、Python)

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://注册账号获取/jd/cat_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&cid=0";
		JSONObject json = getRequestFromUrl(url);
		System.out.println(json.toString());
	}

}

响应参数:

{
	"itmes": {
		"itme": [
			{
				"id": 1319,
				"name": "母婴",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 1672,
				"name": "礼品箱包",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 1320,
				"name": "食品饮料、保健食品",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 6144,
				"name": "珠宝",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 6728,
				"name": "汽车用品",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 1318,
				"name": "运动健康",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 6233,
				"name": "玩具乐器",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 4938,
				"name": "彩票、旅行、充值、票务",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 12218,
				"name": "生鲜",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 12379,
				"name": "整车",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 1713,
				"name": "图书、音像、电子书刊",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 9987,
				"name": "手机",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 737,
				"name": "家用电器",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 652,
				"name": "数码",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 1620,
				"name": "家居家装",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 670,
				"name": "电脑办公",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 6196,
				"name": "厨具",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 1316,
				"name": "个护化妆",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 1315,
				"name": "服饰内衣",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 5025,
				"name": "钟表",
				"pid": 0,
				"root_id": 0
			},
			{
				"id": 11729,
				"name": "鞋靴",
				"pid": 0,
				"root_id": 0
			}
		]
	},
	"translate_status": "",
	"translate_time": 0,
	"language": {
		"default_lang": "cn",
		"current_lang": "cn"
	},
	"error": "",
	"reason": "",
	"error_code": "0000",
	"cache": 0,
	"api_info": "today:2 max:11000",
	"execution_time": "0.044",
	"server_time": "Beijing/2022-04-10 13:57:54",
	"client_ip": "106.60.33.154",
	"call_args": [],
	"api_type": "jd",
	"translate_language": "zh-CN",
	"translate_engine": "google_new",
	"server_memory": "0.73MB",
	"request_id": "gw-4.625271e2e2f0e",
	"last_id": "873879202"
}

API 工具
API SDK调用示例
APISDK下载
API测试工具

如何开通API测试,点击立即开通

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/983350.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号