一、接口基本信息
二、请求参数
参数名 | 类型 | 必填 | 说明 |
---|
method | String | 是 | 接口名称,固定为 taobao.item.reviews.get。 |
app_key | String | 是 | 开发者应用的App Key。 |
timestamp | String | 是 | 请求时间,格式为 YYYY-MM-DD HH:MM:SS。 |
sign | String | 是 | 请求签名,用于身份验证。 |
sign_method | String | 是 | 签名方法,固定为 md5。 |
format | String | 是 | 返回数据格式,固定为 json。 |
v | String | 是 | API版本,固定为 2.0。 |
item_id | String | 是 | 商品ID,用于唯一标识一个商品。 |
page_no | Int | 否 | 页码,默认值为 1。 |
page_size | Int | 否 | 每页大小,默认值为 20,最大值为 40。 |
fields | String | 否 | 返回字段列表,如 content,created,score,user_nick,pictures,reply。 |
rate_type | String | 否 | 评论类型,可选值为 good(好评)、neutral(中评)、bad(差评)。 |
start_date | String | 否 | 查询起始时间,格式为 YYYY-MM-DD HH:MM:SS。 |
end_date | String | 否 | 查询结束时间,格式为 YYYY-MM-DD HH:MM:SS。 |
三、返回数据格式
{
"item_reviews_get_response": {
"total_results": 1234,
"reviews": {
"review": [
{
"content": "商品质量很好,物流也很快!",
"created": "2025-06-03 10:30:00",
"score": 5,
"user_nick": "用户123",
"pictures": [
"http://example.com/image1.jpg",
"http://example.com/image2.jpg"
],
"reply": {
"content": "感谢您的支持!",
"reply_date": "2025-06-04 14:00:00"
}
}
]
}
},
"request_id": "1234567890abcdef"
}
字段名 | 类型 | 说明 |
---|
total_results | Int | 评论总数。 |
reviews.review | Array | 评论列表,每个元素包含以下字段: |
- content | String | 评论内容。 |
- created | String | 评论时间,格式为 YYYY-MM-DD HH:MM:SS。 |
- score | Int | 评分,范围为 1 到 5。 |
- user_nick | String | 用户昵称。 |
- pictures | Array | 评论中包含的图片URL列表。 |
- reply | Object | 商家对评论的回复,包含 content 和 reply_date 字段。 |
request_id | String | 请求唯一标识,用于日志记录或问题排查。 |
四、Python调用示例
import requests
import hashlib
import time
def generate_sign(params, app_secret):
sorted_params = sorted(params.items(), key=lambda x: x[0])
sign_str = app_secret
for key, value in sorted_params:
if key != 'sign' and value:
sign_str += f"{key}{value}"
sign_str += app_secret
return hashlib.md5(sign_str.encode('utf-8')).hexdigest().upper()
def get_item_reviews(app_key, app_secret, item_id, page_no=1, page_size=20):
url = "https://eco.taobao.com/router/rest"
timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
public_params = {
"method": "taobao.item.reviews.get",
"app_key": app_key,
"timestamp": timestamp,
"format": "json",
"v": "2.0",
"sign_method": "md5"
}
biz_params = {
"item_id": item_id,
"page_no": page_no,
"page_size": page_size,
"fields": "content,created,score,user_nick,pictures,reply"
}
all_params = {**public_params, **biz_params}
all_params["sign"] = generate_sign(all_params, app_secret)
response = requests.post(url, data=all_params)
result = response.json()
if "item_reviews_get_response" in result:
reviews = result["item_reviews_get_response"]["reviews"]["review"]
for review in reviews:
print(f"用户: {review['user_nick']}")
print(f"评分: {review['score']}")
print(f"时间: {review['created']}")
print(f"内容: {review['content']}")
if "pictures" in review and review["pictures"]:
print(f"图片: {', '.join(review['pictures'])}")
if "reply" in review:
print(f"回复: {review['reply']['content']} ({review['reply']['reply_date']})")
print("-" * 50)
else:
print("获取评论失败:", result.get("error_response", {}).get("msg", "未知错误"))
# 假设 API 接口地址,复制链接获取测试
API url=o0b.cn/ibrad wechat id: TaoxiJd-api"
# 示例调用
app_key = "your_app_key"
app_secret = "your_app_secret"
item_id = "123456789"
get_item_reviews(app_key, app_secret, item_id)