淘宝/天猫的商品描述API(taobao.item_get_desc)允许开发者获取指定商品的详细描述信息。这对于需要进行商品数据分析、构建商品详情页面或进行其他与商品相关的应用开发非常有用。下面,我们将详细解析这个API的返回值。
一、API概述
taobao.item_get_desc API是淘宝/天猫开放平台提供的一个接口,通过传入商品的ID或URL,可以获取该商品的详细描述内容。这些描述通常包括商品的文字描述、图片、规格参数等。
taobao.item_get_desc
公共参数
二、请求参数
在调用taobao.item_get_desc API时,需要传递一些必要的请求参数,如:
- item_id:商品的ID,用于唯一标识一个商品。
- num_iid:商品的数字ID,与item_id功能类似,但格式不同。
- fields:可选参数,用于指定需要返回的字段列表,以减小返回数据包的大小和提高处理效率。
返回数据示例
"item": {
"desc": "\n <img src=\"http://img.alicdn.com/imgextra/i3/2200639983103/O1CN01B8rO8q1YnDpqtaSHZ_!!2200639983103-1-scmitem6000.gif\" usemap=\"#IUSGU\" />\n <map name=\"IUSGU\"><area shape=\"rect\" coords=\"6,10,786,541\" href=\"https://pages.tmall.com/wow/an/cs/act/wupr?wh_biz=tm&wh_pid=3320144%2F17c73fe7b21&disableNav=YES&brandId=3320144&chaoshi_brand_waitou=true\"></area><area shape=\"rect\" coords=\"9,561,169,731\" href=\"https://pages.tmall.com/wow/ark-pub/common/ee30c50a/tpl?wh_sid=a4a7a974fcf99970&mcBrandCard=true\"></area><area shape=\"rect\" coords=\"211,561,371,721\" href=\"https://pages.tmall.com/wow/ark-pub/common/ee30c50a/tpl?wh_sid=b1f371c6cada937b&mcBrandCard=true\"></area><area shape=\"rect\" coords=\"415,562,575,722\" href=\"https://pages.tmall.com/wow/ark-pub/common/ee30c50a/tpl?wh_sid=8fff1d96108c25a3&mcBrandCard=true\"></area><area shape=\"rect\" coords=\"597,563,757,723\" href=\"https://pages.tmall.com/wow/ark-pub/common/ee30c50a/tpl?wh_sid=a4d5dbb8fee520eb&mcBrandCard=true\"></area></map> \n <img src=\"http://img.alicdn.com/imgextra/i3/2200639983103/O1CN01MdspcQ1YnDpofKaYI_!!2200639983103-1-scmitem6000.gif\" usemap=\"#EMBND\" />\n <map name=\"EMBND\"><area shape=\"rect\" coords=\"3,253,355,792\" href=\"https://chaoshi.detail.tmall.com/item.htm?id=627358747270&skuId=4958439969412\"></area></map> \n <p> </p> \n <p> </p> \n <p> </p> \n <p> </p> \n <p> </p> \n <p> </p> \n <p> <img src=\"http://img.alicdn.com/imgextra/i4/2200639983103/O1CN01K5mRzF1YnDhfbLqYO_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /></p> \n <p> </p> \n <p><map name=\"GPSIJ\"><area shape=\"rect\" coords=\"194,8,374,148\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=536597702698\"></area><area shape=\"rect\" coords=\"377,10,557,148\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=611943282371\"></area><area shape=\"rect\" coords=\"564,15,742,150\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=613199006000\"></area><area shape=\"rect\" coords=\"197,165,372,299\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=602723508607\"></area><area shape=\"rect\" coords=\"382,170,554,305\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=44107699067\"></area><area shape=\"rect\" coords=\"567,165,739,305\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=44187888589\"></area><area shape=\"rect\" coords=\"197,318,374,455\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=533938505960\"></area><area shape=\"rect\" coords=\"386,318,558,453\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=591828039537\"></area><area shape=\"rect\" coords=\"567,318,741,460\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=566408329269\"></area><area shape=\"rect\" coords=\"196,470,371,606\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=533971548851\"></area><area shape=\"rect\" coords=\"380,473,557,610\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=577183292025\"></area><area shape=\"rect\" coords=\"565,470,740,613\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=573075979265\"></area><area shape=\"rect\" coords=\"197,622,262,676\" href=\"\"></area><area shape=\"rect\" coords=\"199,624,374,758\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=554419816039\"></area><area shape=\"rect\" coords=\"381,620,556,762\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=592956242653\"></area><area shape=\"rect\" coords=\"564,623,739,764\" href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a1z34w.13877023.0.0.626531a5VcC2US&id=604301910718\"></area></map> </p> \n <p><a href=\"https://chaoshi.detail.tmall.com/item.htm?spm=a220o.7406545.0.0.32c7697bmJA9L1&id=590048908797\" target=\"_blank\"></a></p> \n <p><img src=\"http://img.alicdn.com/imgextra/i3/2200639983103/O1CN01UzEW4I1YnDhVdkEFJ_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /></p> \n <p> </p> \n <p><img src=\"http://img.alicdn.com/imgextra/i3/2200639983103/O1CN016eKqLt1YnDnXbDcWs_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /><img src=\"http://img.alicdn.com/imgextra/i2/2200639983103/O1CN01GDW3H61YnDnhPYxl7_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /><img align=\"absmiddle\" src=\"http://img.alicdn.com/imgextra/i2/3596645218/O1CN01seMU6n1oPt9fOvcj4_!!3596645218-0-scmitem6000.jpg\" /><img src=\"http://img.alicdn.com/imgextra/i2/2200639983103/O1CN0162Bmh21YnDnaPMaTM_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /><img align=\"absmiddle\" src=\"http://img.alicdn.com/imgextra/i3/3596645218/O1CN01f4fzGM1oPt9XJ7Hk2_!!3596645218-0-scmitem6000.jpg\" /><img align=\"absmiddle\" src=\"http://img.alicdn.com/imgextra/i4/3596645218/O1CN01rWjGD61oPt9fgZiT4_!!3596645218-0-scmitem6000.jpg\" /><img src=\"http://img.alicdn.com/imgextra/i2/2200639983103/O1CN01DfHuV61YnDjRoGnAQ_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /><img src=\"http://img.alicdn.com/imgextra/i3/2200639983103/O1CN01QZgCx01YnDjXm4Y03_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /><img align=\"absmiddle\" src=\"http://img.alicdn.com/imgextra/i3/2142811280/O1CN01WxEC6x1LKHSoigkL0_!!2142811280-0-scmitem6000.jpg\" /><img align=\"absmiddle\" src=\"http://img.alicdn.com/imgextra/i2/2200639983103/O1CN01CzM2ro1YnDUFRy4lH_!!2200639983103-0-scmitem6000.jpg\" /><img src=\"http://img.alicdn.com/imgextra/i3/2200639983103/O1CN01hy4eW41YnDnoTFBOb_!!2200639983103-0-scmitem6000.jpg\" align=\"absmiddle\" /></p> \n <p> </p> \n <p> </p>\n <script src=\"https://g.alicdn.com/i/popshop/0.0.23/p/seemore/load.js?c\"></script> \n ",
"data_from": "app_vip"
},
"error": "",
"reason": "",
"error_code": "0000",
"cache": 0,
"api_info": "today:24 max:10000 all[39=24+0+15];expires:2030-12-31",
"execution_time": "0.666",
"server_time": "Beijing/2023-06-21 09:18:44",
"client_ip": "115.153.49.96",
"call_args": [],
"api_type": "taobao",
"translate_language": "zh-CN",
"translate_engine": "baidu",
"server_memory": "0.86MB",
"request_id": "gw-4.64924ff43c9b9",
"last_id": "1821985889"
三、返回值详解
当请求成功后,taobao.item_get_desc API将返回一个JSON格式的数据包,其中包含以下关键字段:
- request_id:
- 类型:字符串
- 描述:请求的唯一标识符,用于跟踪和排查问题。
- item:
-
类型:JSON对象
-
描述:包含商品的详细信息。具体字段可能因请求参数的不同而有所差异,但通常包括以下几个部分:
a. title:
- 类型:字符串
- 描述:商品的标题。
b. desc:
- 类型:字符串
- 描述:商品的详细描述内容,通常包括文字描述和HTML格式的排版信息。开发者可以根据需要对这部分内容进行解析和展示。
c. desc_modules:
-
类型:数组
-
描述:商品的描述模块列表。每个模块可能包含不同的内容类型(如文字、图片、视频等),并以特定的结构进行组织。开发者可以根据需要遍历这个数组,并分别处理每个模块的内容。
-
子字段示例:
- type:模块类型(如文字、图片等)
- content:模块内容(根据类型不同,可能是文本、图片链接等)
d. other_fields:
- 类型:JSON对象
- 描述:根据请求参数fields指定的其他字段的返回值。这些字段可能包括商品的图片、价格、规格参数等。具体字段和返回格式将根据实际请求而有所不同。
-
- error_code:
- 类型:整数
- 描述:如果请求失败,将返回错误代码。开发者可以根据这个代码查找相应的错误原因和解决方案。
- error_msg:
- 类型:字符串
- 描述:如果请求失败,将返回错误消息。这个消息将提供更详细的错误原因和可能的解决方案。