# 小红书 多链接评论批量采集 API (xiaohongshu.comments_batch)

- Canonical page: https://everyinfra.com/xiaohongshu-api/comments_batch
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "xiaohongshu", "action": "comments_batch", "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 target, no next_page_token (to read further, page one target at a time with the single-target action; limit is ignored)
- Mode: sync only; everything it returns (every target of a batch, or every SKU of a product) is read in one call, and "mode": "async" returns 422 before any charge

小红书多链接评论批量采集用 `urls` 一次读 1–20 篇笔记的评论，每篇笔记读一页，每页最多 15 条。每行是一条一级评论，带正文、点赞数、发布时间和评论者信息，还有 `note_id`、`note_url` 标明它属于哪篇笔记，以及前几条回复 `sub_comments` 和回复总数 `sub_comment_count`。它回答「这一批笔记的评论区里读者各说了什么」，适合给一组种草笔记做口碑对比。

`urls` 里每条链接都要带笔记 ID 和有效的 xsec_token，按目标笔记数计费；`sort` 对这次请求里的每篇笔记都生效。评论回复那一页读的是一条评论下的全部回复，要给父评论 ID；这一页没有这个参数，只随评论带回前几条回复。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| urls | not declared | yes | not declared | comments_batch 的笔记链接数组，一次 1–20 条；每条都须包含笔记 ID 和有效的 xsec_token。按目标笔记数计费；部分目标失败时检查 partial / missed，不把未返回的目标当作没有评论。 |
| sort | enum: default / most_liked / newest | no | not declared | 每篇笔记的评论排序：default 平台默认排序（不传时同此）、newest 最新在前、most_liked 点赞最多在前；对这次请求里的每篇笔记都生效。 |

## 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_batch",
  "params": {
    "urls": [
      "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_batch",
        "params": {
            "urls": [
                "https://www.xiaohongshu.com/explore/6aa7a3f600000000110335f8?xsec_token=YByFNzoKupps8B3qI774Gx7XGxfHpq4QWEvxU4zsD8454%3D",
            ],
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

No real sample for these example parameters yet: structure only, every value is a placeholder (…).

```text
{
  "id": "req_…",
  "platform": "xiaohongshu",
  "action": "comments_batch",
  "results": [
    {
      "id": …,
      "text": …,
      "like_count": …,
      "posted_at": …,
      "ip_location": …,
      "author_name": …,
      "author_id": …,
      "sub_comment_count": …,
      "note_id": …,
      "note_url": …,
      "next_page_token": …,
      "images": …,
      "is_author": …,
      "author_avatar_url": …,
      "author_red_id": …,
      "author_is_ai_agent": …,
      "mentioned_users": …,
      "comment_tags": …,
      "sub_comments": …,
      "platform": …
    }
  ],
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 部分链接失败时怎么办？

先看响应里的 partial 和 missed，找出哪几篇笔记没读到。没有返回的目标不等于没有评论，先确认是不是读取失败，再下结论。

### 批量采集和评论那一页怎么选？

要读很多篇笔记的第一页评论，用批量，一次 1–20 篇；要读某一篇笔记的后几页，用评论那一页逐页翻。批量这一页每篇笔记只返回一页，本身不收 `page_token`，仅支持 `sync`。

### 怎么分清一条评论属于哪篇笔记？

看 `note_id` 和 `note_url`，每行都带，按它们分组就行。`sub_comments` 只有每条评论的前几条回复，总数看 `sub_comment_count`，要取全回复，再调评论回复那一页。

## 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
