淘宝商品评论API接口详细说明

一、接口基本信息

接口名称:taobao.item.review.get

提供方:淘宝开放平台

功能描述:获取指定商品的评论数据,包括文字评论、图片评论、视频评论等,支持分页、筛选、排序等操作。

请求方式:HTTP POST

响应格式:JSON

二、请求参数

参数名类型必填说明

methodString是接口名称,固定为 taobao.item.review.get

app_keyString是开发者应用的App Key。

timestampString是请求时间,格式为 YYYY-MM-DD HH:MM:SS。

signString是请求签名,用于身份验证。

sign_methodString是签名方法,固定为 md5。

formatString是返回数据格式,固定为 json。

vString是API版本,固定为 2.0。

item_idString是商品ID,用于唯一标识一个商品。

page_noInt否页码,默认值为 1。

page_sizeInt否每页大小,默认值为 20,最大值为 40。

fieldsString否返回字段列表,如 content,created,score,user_nick,pictures,reply。

rate_typeString否评论类型,可选值为 good(好评)、neutral(中评)、bad(差评)。

start_dateString否查询起始时间,格式为 YYYY-MM-DD HH:MM:SS。

end_dateString否查询结束时间,格式为 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"

}

Copy

字段名类型说明

total_resultsInt评论总数。

reviews.reviewArray评论列表,每个元素包含以下字段:

- contentString评论内容。

- createdString评论时间,格式为 YYYY-MM-DD HH:MM:SS。

- scoreInt评分,范围为 1 到 5。

- user_nickString用户昵称。

- picturesArray评论中包含的图片URL列表。

- replyObject商家对评论的回复,包含 content 和 reply_date 字段。

request_idString请求唯一标识,用于日志记录或问题排查。

四、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)

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容