一、接口基本信息
二、請求參數
參數名 | 類型 | 必填 | 說明 |
---|
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)