京东业务场景API接口通过商品id获得JD商品详情的接入示例如下:
-
首先,你需要注册一个ApiKey和ApiSecret。
-
然后,使用ApiKey和ApiSecret获取访问令牌(access_token)。
-
最后,使用访问令牌调用item_get接口,传入商品id,获取商品的详细信息。
以下是一个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://item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=10335871600"
headers = {
"Accept-Encoding": "gzip",
"Connection": "close"
}
if __name__ == "__main__":
r = requests.get(url, headers=headers)
json_obj = r.json()
print(json_obj)
请将上述代码中的your_api_key
、your_api_secret
和your_item_id
替换为你自己的ApiKey、ApiSecret和商品id。运行代码后,你将得到商品的详细信息。
API接口请求响应示例
{
"item": {
"num_iid": "10043260140850",
"title": "大宇(DAEWOO)电煮锅家用宿舍小型1.2L多功能煮面锅 DYZM-1266 DYZM-1266",
"desc_short": "",
"price": 278,
"total_price": "",
"suggestive_price": "",
"orginal_price": 278,
"nick": "大宇厨房电器旗舰店",
"num": 100,
"detail_url": "https://item.jd.com/10043260140850.html",
"pic_url": "http://img13.360buyimg.com/n12/jfs/t1/138059/9/25193/136416/61c9709cE63cc1079/39caacb471c923ea.jpg",
"brand": "大宇(DAEWOO)",
"brandId": "",
"rootCatId": "",
"cid": 754,
"desc": "<p ><img src=\"//img30.360buyimg.com/popWareDetail/jfs/t1/114937/16/36636/30328/64758c19F79424976/a1f1171441ba1ed6.jpg\"/><img src=\"//img30.360buyimg.com/popWareDetail/jfs/t1/217525/16/30285/132826/64758c1aF99a973e5/11baa26bf23f3ff0.jpg\"/><img src=\"//img30.360buyimg.com/popWareDetail/jfs/t1/218936/10/23890/144371/64758c1aF04dfadc0/55a2ee89f248ec77.jpg\"/><img src=\"//img30.360buyimg.com/popWareDetail/jfs/t1/146050/18/36711/152939/64758c1aF208442fd/53eb2dd7dd7282eb.jpg\"/><img src=\"//img30.360buyimg.com/popWareDetail/jfs/t1/58881/31/24817/35120/64758c1aFed5cd40a/77b9b5ee08f5798b.jpg\"/><img src=\"//img30.360buyimg.com/popWareDetail/jfs/t1/120182/38/32651/117602/64758c1bFeeb8769d/0b1bcbd45f30d198.jpg\"/><img src=\"//img30.360buyimg.com/popWareDetail/jfs/t1/137552/1/33844/26156/64758c1bFd4135587/bd457c29a94c7cde.jpg\"/><img src=\"//img30.360buyimg.com/popWareDetail/jfs/t1/99007/1/32550/152400/64758c1bF85d870bd/e749a876b5cb9888.jpg\"/><img src=\"//img30.360buyimg.com/popWareDetail/jfs/t1/146307/20/37627/26726/64758c1bF13650665/39470333804f5bc5.jpg\"/><img src=\"//img30.360buyimg.com/popWareDetail/jfs/t1/101637/23/33466/105731/64758c1cFb8c28471/fd1cb094e9405a4e.jpg\"/><img src=\"//img30.360buyimg.com/popWareDetail/jfs/t1/87451/8/40472/160963/64758c1cF5ccf4619/b9fb935e00beca14.jpg\"/><img src=\"//img30.360buyimg.com/popWareDetail/jfs/t1/156202/6/37534/56173/64758c1cFa085bf3b/6f46ccd24a22875e.jpg\"/><img src=\"//img30.360buyimg.com/popWareDetail/jfs/t1/91540/7/27986/51302/64758c1dF862f3d7f/0f84002c76bb9e99.jpg\"/><br/></p><p><br/></p><br/><img src=\"https://www.o0b.cn/i.php?t.png&rid=gw-3.660cc825b6cc3&p=1778787742&k=i_key&t=1712113706\" style=\"display:none\" />",
"item_imgs": [
{
"url": "http://img13.360buyimg.com/n12/jfs/t1/138059/9/25193/136416/61c9709cE63cc1079/39caacb471c923ea.jpg"
},
{
"url": "http://img13.360buyimg.com/n12/jfs/t1/171649/19/24115/120559/61c9709cE00801046/8a997e03fa15a8ea.jpg"
},
{
"url": "http://img13.360buyimg.com/n12/jfs/t1/221451/25/7298/119272/61c9709cE3e412d08/aaeb3eb15c475e3e.jpg"
},
{
"url": "http://img13.360buyimg.com/n12/jfs/t1/214031/26/9331/149981/61c9709cEa1a8b1fd/d366643430e3da18.jpg"
},
{
"url": "http://img13.360buyimg.com/n12/jfs/t1/158383/12/24164/120347/61c9709cE969d9f4d/46ad963f71bf230a.jpg"
},
{
"url": "http://img13.360buyimg.com/n12/jfs/t1/170923/13/29100/48458/61c9709bEd328096b/719a4c24ed191b95.jpg"
},
{
"url": "http://img13.360buyimg.com/n12/jfs/t1/168033/24/23493/66443/61c9709bE700c943c/4a3035b33d603937.jpg"
},
{
"url": "http://img13.360buyimg.com/n12/jfs/t1/209484/37/14012/43562/61c9709bEc6f1ca0b/5c0f389a2f0fa816.jpg"
},
{
"url": "http://img13.360buyimg.com/n12/jfs/t1/210608/28/14075/60135/61c9709bEb2a7ff47/b091630e5314c283.jpg"
}
],
"item_weight": "",
"post_fee": "",
"freight": "",
"express_fee": "",
"ems_fee": "",
"shipping_to": "",
"video": {
"url": "https://jvod.300hu.com/vod/product/707af77d-3caa-4382-ae91-65c0c838d575/f844f141cca94deb971ca9d42be60823.mp4"
},
"sample_id": "",
"props_name": "",
"prop_imgs": {
"prop_img": []
},
"props_imgs": {
"prop_img": []
},
"property_alias": "",
"props": [
{
"name": "商品名称",
"value": "大宇(DAEWOO)DYZM-1266 "
},
{
"name": "商品编号",
"value": "10043260140850"
},
{
"name": "店铺",
"value": " 大宇厨房电器旗舰店"
},
{
"name": "商品毛重",
"value": "1.2kg"
},
{
"name": "类型",
"value": "电煮锅"
},
{
"name": "能效等级",
"value": "无能效等级"
},
{
"name": "容量",
"value": "2L及以下"
},
{
"name": "操控方式",
"value": "机械式"
},
{
"name": "品牌",
"value": "大宇(DAEWOO)"
}
],
"total_sold": "-1",
"skus": {
"sku": []
},
"seller_id": "11586068",
"sales": null,
"shop_id": "",
"props_list": [],
"seller_info": {
"nick": "大宇厨房电器旗舰店",
"user_num_id": "11586068",
"sid": "",
"zhuy": "https://mall.jd.com/index-11586068.html",
"shop_name": "大宇厨房电器旗舰店"
},
"location": null,
"data_from": "ha",
"props_img": [],
"shop_item": [],
"relate_items": []
},
"secache": "ce860021c5336ba001a40f555d1ab6aa",
"secache_time": 1712113706,
"secache_date": "2024-04-03 11:08:26",
"translate_status": "",
"translate_time": 0,
"language": {
"default_lang": "cn",
"current_lang": "cn"
},
"error": "",
"reason": "",
"error_code": "0000"