# 小红书 评论 API (xiaohongshu.comments)

- Canonical page: https://everyinfra.com/xiaohongshu-api/comments
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "xiaohongshu", "action": "comments", "params": {...}}
- Price: $0.005556 per call ($5.56 per 1,000 requests); failed calls and empty results are not charged
- Returns: list, one page of 15 per call (limit is ignored; pass the top-level next_page_token from the response as page_token for the next page)
- Pagination: pass next_page_token back as page_token for the next page, other params unchanged; one call per page, tokens last 24 hours
- Mode: sync; add "mode": "async" for slow tasks

小红书评论接口按笔记 `url` 读取这篇笔记下的一级评论，每条带正文、点赞数、发布时间、IP 归属地、评论者昵称和小红书号，以及这条评论下的回复数。它回答「读者对这篇笔记怎么说」，常用于口碑分析、产品反馈收集和种草效果评估。

用 `sort` 选平台默认、最新或点赞最多的顺序；翻页时把 `next_page_token` 填进 `page_token`，每页 15 条。`sub_comment_count` 只给回复数，回复内容要另外读评论回复；`is_author` 标出笔记作者本人的评论，`author_is_ai_agent` 标出平台标记的 AI 账号，做情感分析前可以先把它们分开。几篇笔记的评论放进一张表时，靠 `note_id` 区分来源。

## Health

- Live health (24h percent, hourly and daily trends): https://api.everyinfra.com/api/v1/social/availability?platform=xiaohongshu&action=comments

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| url | not declared | yes | not declared | 小红书笔记完整链接，路径为 /explore/<笔记ID> 或 /discovery/item/<笔记ID>；优先使用近期搜索结果中的完整 URL，保留 xsec_token 等查询参数。sub_comments 还需同一笔记下的 comment_id。 |
| page_token | not declared | no | not declared | 翻页游标（comments、sub_comments、search、user_posts、search_users、hashtag）：把上一次返回结果行里的 next_page_token 原样传入就拿下一页；不传从第一页开始。每页算一次调用，按次计费。 |
| sort | enum: default / most_liked / newest | no | not declared | 评论排序：default 平台默认排序（不传时同此）、newest 最新在前、most_liked 点赞最多在前。翻页时保持同一个取值（换了取值，上一页的 next_page_token 不再适用）。default 是平台的推荐顺序，每次请求都会重新排，排名一变，翻页就会漏掉或重复一部分评论；newest 按时间排、翻页稳定，但有的笔记平台只给最新的一部分。所以翻到没有 next_page_token，只说明平台说没有下一页，不保证已经拿到全部评论；用 default 时多翻几轮、按评论 id 合并能补回一部分。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| text | 笔记正文或评论内容。note、hashtag 返回笔记全文；search、user_posts 返回的笔记正文可能是截断的摘要（分别约 60 字、100 字以内），要全文用笔记 ID 调 note。reviews 是商品评价的全文。 |
| like_count | 点赞数。笔记、评论类结果是这条内容的点赞数；reviews 是这条商品评价被点「有用」的次数；profile 里是该账号所有笔记累计获得的点赞数。null 表示不公开或这次没拿到，不等于 0。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| ip_location | 小红书展示的 IP 归属地（省份/国家），平台强制显示，非用户填写。user_posts 只有部分笔记带。 |
| author_name | 作者昵称（显示名）。 |
| author_id | 作者的用户 ID，可直接传给 profile、user_posts。笔记类结果里是 24 位，与主页链接里的 ID 相同；评论类结果（comments、comments_batch、sub_comments）里多为 29 位的另一种写法。同一个人的两种写法不同，跨批次去重前先用 profile 换成它返回的 user_id。 |
| sub_comment_count | 该条评论下的回复数（楼中楼）。 |
| note_id | 笔记 ID，评论类能力用它回指所属笔记。 |
| note_url | 所属笔记链接。 |
| next_page_token | 翻页游标：同一页每行的值相同，原样作为下一次请求的 page_token 就取下一页，其余参数保持不变；为空或没有这个字段表示没有下一页。能传 page_token 的是 search、user_posts、comments、sub_comments、search_users、hashtag、product_search、pgy_content_square、reviews、followers_list；comments_batch 行上也带这一项，但它本身不收 page_token。 |
| images | 图片链接列表。note、hashtag、search、user_posts 是笔记的全部图片（按原顺序）；评论类结果（comments、comments_batch、sub_comments）是评论所附的图片，含表情包贴图，没有图片时为空数组；reviews 是买家晒的图，没有晒图时为空数组。null 表示这次没拿到这一项。 |
| is_author | 这条评论是不是笔记作者本人写的。null 表示这次没拿到这一项，不等于 false。 |
| author_avatar_url | 评论者的头像链接（comments、comments_batch、sub_comments）。 |
| author_red_id | 作者的小红书号：评论类结果（comments、comments_batch、sub_comments）是评论者的，note、search 是笔记作者的。 |
| author_is_ai_agent | 评论者是不是平台标记的 AI 账号；这次没拿到这一项时没有这个字段。 |
| mentioned_users | 被 @ 的人：评论类结果是评论里 @ 的人，note 是笔记里 @ 的人；每项有 user_id、nickname。没有时没有这个字段。 |
| comment_tags | 评论标签（comments、comments_batch、sub_comments），每项 type（is_author 作者、note_first 首评、user_top 置顶、product_review 商品评价等）与 text（展示文字，可能是中文或英文）；没有标签时为空数组。 |
| sub_comments | 评论自带的前几条回复（comments、comments_batch），每条与 sub_comments 接口的行同形；只是其中几条，总数看 sub_comment_count，要取全请调 sub_comments。没有回复时为空数组。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |

## Example

```bash
curl -X POST 'https://api.everyinfra.com/api/v1/social' \
  -H "Authorization: Bearer $EVERYINFRA_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "platform": "xiaohongshu",
  "action": "comments",
  "params": {
    "url": "https://www.xiaohongshu.com/explore/6aa7a3f600000000110335f8?xsec_token=YByFNzoKupps8B3qI774Gx7XGxfHpq4QWEvxU4zsD8454%3D"
  }
}'
```

```python
import os
import requests

response = requests.post(
    "https://api.everyinfra.com/api/v1/social",
    headers={"Authorization": f"Bearer {os.environ['EVERYINFRA_API_KEY']}"},
    json={
        "platform": "xiaohongshu",
        "action": "comments",
        "params": {
            "url": "https://www.xiaohongshu.com/explore/6aa7a3f600000000110335f8?xsec_token=YByFNzoKupps8B3qI774Gx7XGxfHpq4QWEvxU4zsD8454%3D",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

Real response to the example request above, captured 2026-10-15T15:16:12Z. `results` and `count` are real with personal information (names, handles, avatars, profile links, contact details) removed; the list keeps the first 2 of 10. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "xiaohongshu",
  "action": "comments",
  "results": [
    {
      "id": "6aa80e9b000000000200c6ad",
      "text": "一点不像33平米的  感觉远不止  我住的45平在规划设计下 都很小",
      "like_count": 41,
      "posted_at": "2026-09-14T15:11:23+00:00",
      "author_name": "•••",
      "author_id": "•••",
      "sub_comment_count": 7,
      "note_id": "6aa7a3f600000000110335f8",
      "note_url": "https://www.xiaohongshu.com/explore/6aa7a3f600000000110335f8?xsec_token=YByFNzoKupps8B3qI774Gx7XGxfHpq4QWEvxU4zsD8454%3D",
      "next_page_token": "n1.6abba9cd000000001001c13b",
      "images": [],
      "is_author": false,
      "author_avatar_url": "https://sns-avatar-qc-ae.rednotecdn.com/•••",
      "author_red_id": "•••",
      "author_is_ai_agent": false,
      "platform": "xiaohongshu"
    },
    {
      "id": "6aa7dbde000000000a027007",
      "text": "房屋原博主有小红书吗",
      "like_count": 5,
      "posted_at": "2026-09-14T11:34:54+00:00",
      "author_name": "•••",
      "author_id": "•••",
      "sub_comment_count": 4,
      "note_id": "6aa7a3f600000000110335f8",
      "note_url": "https://www.xiaohongshu.com/explore/6aa7a3f600000000110335f8?xsec_token=YByFNzoKupps8B3qI774Gx7XGxfHpq4QWEvxU4zsD8454%3D",
      "next_page_token": "n1.6abba9cd000000001001c13b",
      "images": [],
      "is_author": false,
      "author_avatar_url": "https://sns-avatar-qc-ae.rednotecdn.com/•••",
      "author_red_id": "•••",
      "author_is_ai_agent": false,
      "platform": "xiaohongshu"
    }
  ],
  "next_page_token": …,
  "pagination": { … },
  "count": 10,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 怎么拿到评论下面的回复？

这个接口只返回一级评论，`sub_comment_count` 是每条评论下的回复数。需要回复内容时，用同一篇笔记的链接和这条评论的 `id`，调小红书的评论回复能力。每条评论自带的 `sub_comments` 只是前几条回复，结构和评论回复的结果行一样，适合快速预览；数量对不上 `sub_comment_count` 时，才值得为这条评论单独展开；没有回复时它是空数组。

### 翻页能拿到全部评论吗？

不一定。`sort` 取 `default`（不传时同此）时，平台每次请求都会重新排序，下一页只能从上一页最后一条评论接着取，排名一变就会漏掉或重复一部分评论。`newest` 按发布时间排，翻页稳定，但有的笔记平台只给最新的一部分。所以没有 `next_page_token` 只说明平台说没有下一页，不代表已经拿全。用 `default` 时，多翻几轮、按评论 `id` 合并能补回一部分。中途换了 `sort` 要从第一页重读。

### 评论者的 ID 能和笔记作者的 ID 对上吗？

不能直接对上。评论类结果里的 `author_id` 多为另一种写法，和笔记结果、主页链接里的 ID 不同；跨批次去重前，先用主页资料能力把它换成统一的用户 ID。不换 ID 也能先认人：`author_red_id` 是评论者的小红书号，头像在 `author_avatar_url`，评论里直接带着。`comment_tags` 标出作者、首评、置顶和商品评价等标签，展示文字可能是中文也可能是英文，归类时看每项的 type。

## Also

- Capability catalog (no key): https://api.everyinfra.com/api/v1/social/catalog?platform=xiaohongshu
- OpenAPI: https://everyinfra.com/openapi.json · Agents guide: https://everyinfra.com/agents.md
