# 小红书 关键词搜索 API (xiaohongshu.search)

- Canonical page: https://everyinfra.com/xiaohongshu-api/search
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "xiaohongshu", "action": "search", "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 20 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

小红书关键词搜索按 `keyword` 检索笔记内容，每次返回一页笔记卡片：标题、正文摘要、点赞与收藏数、作者和发布时间；视频笔记还带播放地址 `video_url` 和时长 `duration_sec`，标了地点的卡片带 `poi_name`。它回答「这个话题下最近有什么笔记、哪些互动高」，常用于选题调研、种草效果监测和舆情抽样。

用 `sort` 按最新、点赞、评论或收藏排序，用 `date_range` 只看最近 24 小时、7 天、一个月、半年或一年，用 `content_type` 只看图文或视频。`text` 是截断的摘要，要全文请用结果里的 `url` 再调笔记详情；`like_count`、`collect_count` 为 null 表示这次没拿到，不等于 0。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | 小红书笔记搜索词，传一个字符串，如 敏感肌防晒；搜索的是笔记内容，不是用户 ID。 |
| content_type | enum: all / image / video | no | not declared | 按笔记类型筛选结果，具体类型与取值见当前接口的允许值列表。 |
| date_range | enum: any_time / last_1_year / last_24_hours / last_30_days / last_6_months / last_7_days | no | not declared | 按笔记发布时间筛选：any_time 不限（不传时同此）、last_24_hours 最近 24 小时、last_7_days 最近 7 天、last_30_days 最近一个月、last_6_months 最近半年、last_1_year 最近一年。last_30_days 和 last_1_year 一页可能不足 20 条，一条都没有的页不收费；想要更满的页请配 sort=newest；这两档只能同步调用。翻页时保持同一个取值。 |
| page_token | not declared | no | not declared | 翻页游标（comments、sub_comments、search、user_posts、search_users、hashtag）：把上一次返回结果行里的 next_page_token 原样传入就拿下一页；不传从第一页开始。每页算一次调用，按次计费。 |
| sort | enum: most_collected / most_commented / most_liked / newest / relevance | no | not declared | search 的笔记列表排序：relevance 相关度、newest 最新、most_liked 点赞最多、most_commented 评论最多、most_collected 收藏最多；只使用当前接口列出的允许值。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在小红书上的链接。search、note、profile、hashtag 返回的链接一般带访问令牌，未登录的浏览器也能打开（令牌有时效，过期后重新调用即可）；user_posts 返回的笔记链接不带令牌，在浏览器里打开需要令牌：用笔记 ID 调 note 能拿到可以打开的链接；search_users 返回的主页链接同样不带令牌，用 user_id 调 profile 拿能打开的链接。pgy_content_square 不带 keyword 时笔记链接带令牌，带 keyword 时不带（用笔记 ID 调 note 拿能打开的链接）。followers_list 返回的是粉丝的主页链接，同样不带令牌；note_location 返回的笔记链接带上了请求里的令牌（请求里没带就没有）。 |
| title | 标题。平台无标题概念时（如纯文本帖）为 null。 |
| text | 笔记正文或评论内容。note、hashtag 返回笔记全文；search、user_posts 返回的笔记正文可能是截断的摘要（分别约 60 字、100 字以内），要全文用笔记 ID 调 note。reviews 是商品评价的全文。 |
| like_count | 点赞数。笔记、评论类结果是这条内容的点赞数；reviews 是这条商品评价被点「有用」的次数；profile 里是该账号所有笔记累计获得的点赞数。null 表示不公开或这次没拿到，不等于 0。 |
| collect_count | 收藏数。笔记类结果是这篇笔记被收藏的次数；profile 里是该账号笔记累计被收藏的次数。null 表示不公开或这次没拿到，不等于 0。 |
| comment_count | 评论数。null 表示不公开，不等于 0。 |
| share_count | 分享/转发数。null 表示不公开，不等于 0。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| image_url | 图片链接。多图能力可能返回 image_urls 数组。 |
| author_name | 作者昵称（显示名）。 |
| author_id | 作者的用户 ID，可直接传给 profile、user_posts。笔记类结果里是 24 位，与主页链接里的 ID 相同；评论类结果（comments、comments_batch、sub_comments）里多为 29 位的另一种写法。同一个人的两种写法不同，跨批次去重前先用 profile 换成它返回的 user_id。 |
| avatar_url | 头像图片链接。部分平台给的是带尺寸参数的 CDN 链接，可能有时效。 |
| author_url | 作者主页链接，不带访问令牌，未登录的浏览器打不开；用 author_id 调 profile 返回的 url 可以直接打开。 |
| is_video | 是否视频笔记。视频播放地址不在详情返回里（2026-10-14 起）：要地址请用同一篇笔记的 url 单独调用 video 接口，按次计费。 |
| 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。 |
| video_url | 视频播放地址（mp4），带签名、会过期，要留存请及时下载。图文笔记或这次没拿到时为 null。search/user_posts 行与 video 接口返回；note 详情不含（2026-10-14 起要地址请单独调用 video 接口）。 |
| duration_sec | 视频时长，单位秒。图文笔记或这次没拿到时为 null。 |
| duration_seconds | 时长，单位秒。非视频/音频内容为 null。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |
| poi_id | 搜索结果卡片上标的地点 ID（search）；没标地点时没有这个字段。 |
| poi_name | 地点名称：search 是搜索结果卡片上标的地点；note_location 是笔记标的发布地点里「·」后面的那段（如 星巴克(国贸店)）。没标地点或标了多个地点时没有这个字段。 |
| images | 图片链接列表。note、hashtag、search、user_posts 是笔记的全部图片（按原顺序）；评论类结果（comments、comments_batch、sub_comments）是评论所附的图片，含表情包贴图，没有图片时为空数组；reviews 是买家晒的图，没有晒图时为空数组。null 表示这次没拿到这一项。 |
| is_goods_note | 是否带货笔记（search、user_posts）。 |
| is_cooperation_note | 是否为品牌商业合作笔记（search、note）；拿不到这一项时没有这个字段。 |
| author_is_verified | 作者是否官方认证（note、search）。 |
| updated_at | 笔记最后编辑时间（search、note；ISO 8601，UTC）；没编辑过时可能与 posted_at 接近或缺省。 |
| author_red_id | 作者的小红书号：评论类结果（comments、comments_batch、sub_comments）是评论者的，note、search 是笔记作者的。 |
| video_width | 视频画面宽度（像素，search、video）。 |
| video_height | 视频画面高度（像素，search、video）。 |

## 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": "search",
  "params": {
    "keyword": "小户型收纳"
  }
}'
```

```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": "search",
        "params": {
            "keyword": "小户型收纳",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

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

```text
{
  "id": "req_…",
  "platform": "xiaohongshu",
  "action": "search",
  "results": [
    {
      "id": "6a55fff400000000110058c3",
      "url": "https://www.xiaohongshu.com/explore/6a55fff400000000110058c3?xsec_token=YBwgl4W48szr36c1jFWrf2WWLLGDKYfA5rrXQivgGAj1A%3D",
      "title": "抽屉乱救星！亚克力薄抽治愈收纳焦虑｜附教程",
      "text": "我发现这种又薄、还自带分隔的亚克力薄抽，简直就是为收纳小工具小零件而生的。今天就来分享详细的改造教程，评论区等你们交作业",
      "like_count": 10388,
      "collect_count": 19173,
      "comment_count": 257,
      "share_count": 2323,
      "posted_at": "2026-07-14T09:23:00+00:00",
      "image_url": "https://sns-na-i6.xhscdn.com/1040g2sg322jlesv1mse043d8j25m1nmqtti8mog?imageView2/2/w/608/format/heif/q/56|imageMogr2/strip&redImage/frame/0/enhance/4&ap=5&sc=SRH_PRV&sign=b642658d19400d337f2d5296494687c7&t=6ad0ee01",
      "author_name": "•••",
      "author_id": "•••",
      "avatar_url": "https://sns-avatar-qc.xhscdn.com/•••",
      "author_url": "https://www.xiaohongshu.com/•••",
      "is_video": true,
      "next_page_token": "n1.p2",
      "video_url": "http://sns-video-v6.xhscdn.com/stream/79/110/258/01ea55fdf56356a44f0370019f5ff0eb8f_258.mp4?sign=734255c44c5f43e96d8b4a12707707a8&t=6ad58b41",
      "duration_sec": 124,
      "platform": "xiaohongshu"
    },
    {
      "id": "6ac221730000000015002ebb",
      "url": "https://www.xiaohongshu.com/explore/6ac221730000000015002ebb?xsec_token=YBPVyCh77T_2_QF6CFfJ2TiJ8GngzcLJj_Iho466OzP5o%3D",
      "title": "鬼才🔥3平开放式小厨房超实用设计！",
      "text": "#家的1%幸福效应  #howto装扮我的家  #适己化装修  #小户型也有完美厨房  #开放式厨房  #利用厨房空间",
      "like_count": 38783,
      "collect_count": 30796,
      "comment_count": 1021,
      "share_count": 6986,
      "posted_at": "2026-10-04T09:50:43+00:00",
      "image_url": "https://sns-na-i6.xhscdn.com/1040g008325t8oj9j4q005pl7le7nc96up4p8rk8?imageView2/2/w/608/format/heif/q/56|imageMogr2/strip&redImage/frame/0/enhance/4&ap=5&sc=SRH_PRV&sign=ee3e432a917938b82ba55751f30a860e&t=6ad0ee01",
      "author_name": "•••",
      "author_id": "•••",
      "avatar_url": "https://sns-avatar-qc.xhscdn.com/•••",
      "author_url": "https://www.xiaohongshu.com/•••",
      "is_video": true,
      "next_page_token": "n1.p2",
      "video_url": "http://sns-video-v6.xhscdn.com/stream/1/110/258/01eac221721521f001037001a106536b1a_258.mp4?sign=e98d44d7b6f666dc2c4e841655d8c578&t=6ad58b41",
      "duration_sec": 189,
      "platform": "xiaohongshu",
      "poi_id": "42303030413832584538"
    }
  ],
  "next_page_token": …,
  "pagination": { … },
  "count": 20,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 搜索结果里的正文为什么不完整？

搜索结果卡片上的 `text` 是平台给的摘要，通常只有几十个字。需要全文时，把结果行里的 `url` 传给笔记详情，那里返回笔记全文和全部图片；这个链接本身带访问令牌，可以直接用。

### 怎么拿下一页？

把这一页响应顶层的 `next_page_token` 原样作为 `page_token` 再调一次，其他参数保持不变；不传 `page_token` 就从第一页开始。每一页算一次调用，没有返回数据的调用不扣费。

### 视频笔记的播放地址从哪里拿？

搜索结果行里的 `video_url` 就是视频播放地址（mp4，带签名、会过期，要留存请及时下载），`duration_sec` 是时长，图文笔记这两项为 null。笔记详情不返回播放地址；手里只有笔记链接时，用小红书的视频详情能力单独读取。

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