根据商品的父类目id查询子类目id信息,通常用获取各级类目对应关系,以便将推广商品归类。业务参数parentId、grade都输入0可查询所有一级类目ID,之后再用其作为parentId查询其子类目。
【请求参数、 调用方式 GET/POST,支持高并发】
请求参数:cid=0
参数说明:cid:商品分类ID,可以用cid=0来获得所有一级类目
【公共参数】
名称 | 类型 | 必须 | 描述 |
---|---|---|---|
key | String | 是 | 调用key(必须以GET方式拼接在URL中,点击获取调用key和secret) |
secret | String | 是 | 调用密钥 ( 接口代码教程wechat 19970108018 ) |
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版本 |
【 响应参数】
名称 | 类型 | 是否隐私 | 示例值 | 描述 |
---|---|---|---|---|
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…) 】
- # coding:utf-8
- """
- Compatible for python2.x and python3.x
- requirement: pip install requests
- """
- from __future__ import print_function
- import requests
- # 请求示例 url 默认请求参数已经做URL编码
- url = "https://wx19970108018/jd/cat_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&cid=0"
- headers = {
- "Accept-Encoding": "gzip",
- "Connection": "close"
- }
- if __name__ == "__main__":
- r = requests.get(url, headers=headers)
- json_obj = r.json()
- print(json_obj)
【响应示例】
- {
- code: 200,
- msg: "请求成功【success】",
- data: [
- {
- grade: 0,
- name: "数码",
- id: 652,
- parentId: 0
- },
- {
- grade: 0,
- name: "电脑、办公",
- id: 670,
- parentId: 0
- },
- {
- grade: 0,
- name: "家用电器",
- id: 737,
- parentId: 0
- },
- {
- grade: 0,
- name: "食品饮料",
- id: 1320,
- parentId: 0
- },
- {
- grade: 0,
- name: "服饰内衣",
- id: 1315,
- parentId: 0
- },
- {
- grade: 0,
- name: "美妆护肤",
- id: 1316,
- parentId: 0
- },
- {
- grade: 0,
- name: "运动户外",
- id: 1318,
- parentId: 0
- },
- {
- grade: 0,
- name: "母婴",
- id: 1319,
- parentId: 0
- },
- {
- grade: 0,
- name: "家居日用",
- id: 1620,
- parentId: 0
- },
- {
- grade: 0,
- name: "图书",
- id: 1713,
- parentId: 0
- },
- {
- grade: 0,
- name: "礼品",
- id: 1672,
- parentId: 0
- },
- {
- grade: 0,
- name: "文娱",
- id: 4053,
- parentId: 0
- },
- {
- grade: 0,
- name: "本地生活/旅游出行",
- id: 4938,
- parentId: 0
- },
- {
- grade: 0,
- name: "钟表",
- id: 5025,
- parentId: 0
- },
- {
- grade: 0,
- name: "数字内容",
- id: 5272,
- parentId: 0
- },
- {
- grade: 0,
- name: "厨具",
- id: 6196,
- parentId: 0
- },
- {
- grade: 0,
- name: "珠宝首饰",
- id: 6144,
- parentId: 0
- },
- {
- grade: 0,
- name: "玩具乐器",
- id: 6233,
- parentId: 0
- },
- {
- grade: 0,
- name: "宠物生活",
- id: 6994,
- parentId: 0
- },
- {
- grade: 0,
- name: "汽车用品",
- id: 6728,
- parentId: 0
- },
- {
- grade: 0,
- name: "医药保健",
- id: 9192,
- parentId: 0
- },
- {
- grade: 0,
- name: "家装建材",
- id: 9855,
- parentId: 0
- },
- {
- grade: 0,
- name: "家具",
- id: 9847,
- parentId: 0
- },
- {
- grade: 0,
- name: "手机通讯",
- id: 9987,
- parentId: 0
- },
- {
- grade: 0,
- name: "鞋靴",
- id: 11729,
- parentId: 0
- },
- {
- grade: 0,
- name: "生鲜",
- id: 12218,
- parentId: 0
- },
- {
- grade: 0,
- name: "酒类",
- id: 12259,
- parentId: 0
- },
- {
- grade: 0,
- name: "团购",
- id: 12367,
- parentId: 0
- },
- {
- grade: 0,
- name: "整车",
- id: 12379,
- parentId: 0
- },
- {
- grade: 0,
- name: "农资园艺",
- id: 12473,
- parentId: 0
- },
- {
- grade: 0,
- name: "处方药",
- id: 13314,
- parentId: 0
- },
- {
- grade: 0,
- name: "教育培训",
- id: 13678,
- parentId: 0
- },
- {
- grade: 0,
- name: "二手商品",
- id: 13765,
- parentId: 0
- },
- {
- grade: 0,
- name: "邮币",
- id: 13887,
- parentId: 0
- },
- {
- grade: 0,
- name: "IP",
- id: 13996,
- parentId: 0
- },
- {
- grade: 0,
- name: "工业品",
- id: 14065,
- parentId: 0
- },
- {
- grade: 0,
- name: "房地产",
- id: 15083,
- parentId: 0
- },
- {
- grade: 0,
- name: "艺术品",
- id: 15126,
- parentId: 0
- },
- {
- grade: 0,
- name: "家纺",
- id: 15248,
- parentId: 0
- },
- {
- grade: 0,
- name: "家庭清洁/纸品",
- id: 15901,
- parentId: 0
- },
- {
- grade: 0,
- name: "京东服务",
- id: 15980,
- parentId: 0
- },
- {
- grade: 0,
- name: "个人护理",
- id: 16750,
- parentId: 0
- },
- {
- grade: 0,
- name: "箱包皮具",
- id: 17329,
- parentId: 0
- },
- {
- grade: 0,
- name: "非遗",
- id: 18528,
- parentId: 0
- }
- ]
- }