> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.beatapi.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.beatapi.io/_mcp/server.

# 小红书的 xsec_token、x-s、x-t 和 300011 报错分别是什么？

> 解析小红书 xsec_token 访问令牌、x-s/x-t 请求签名与 300011/300012/300013 风控码的技术含义，以及免 Cookie 的 BeatAPI 替代调用（$0.03/次）。

`xsec_token`、`x-s` 与 `x-t` 是小红书用于访问控制与请求校验的反爬参数，`300011`、`300012` 和 `300013` 是登录态小红书爬虫触发风控后返回的账号或会话异常码。通过 BeatAPI（`POST https://api.beatapi.io/v1/social-data/call` 或 `https://beatapi.io/mcp`）调用小红书时，签名与路由均在 BeatAPI 网关侧完成，笔记搜索、详情与评论单价 `$0.03` / 次（蒲公英 `$0.06` / 次；2026-11-24 核验；网关失败调用收费 `$0`）。

## 小红书反爬参数与风控错误码对照

| 参数 / 错误码                | 小红书中的含义                                                   | 直连爬虫失败原因                                                          |
| ----------------------- | --------------------------------------------------------- | ----------------------------------------------------------------- |
| **`xsec_token`**        | 搜索或信息流接口附在笔记链接里的短时访问令牌（`?xsec_token=...&xsec_source=...`） | 打开裸 `/explore/<note_id>` 链接且缺少新鲜有效的 `xsec_token`，常返回 404、空详情或登录拦截 |
| **`x-s` 与 `x-t`**       | 前端混淆 JS 生成的签名请求头（`x-s` 配合 `x-s-common`）与毫秒时间戳（`x-t`）      | 小红书前端包更新后，本地签名脚本失效并触发 HTTP `461`                                  |
| **`300011`**            | 账号异常或登录态风控拦截                                              | 本地 Playwright 脚本与 `xiaohongshu-mcp` 运行在云服务器或海外 IP 时高频触发           |
| **`300012` / `300013`** | 会话校验或频控风控码                                                | 表示 `web_session` + `a1` Cookie 或出口 IP 已被限流或要求人工过验证码               |

## 免 Cookie 调用 BeatAPI 小红书动作

向 `POST https://api.beatapi.io/v1/social-data/call` 传入 `keyword`、`note_id` 或 `share_text`，无需提取 `xsec_token`、计算 `x-s`/`x-t` 或携带 `web_session` Cookie：

**`搜索小红书笔记 ($0.03)`**

```bash title="搜索小红书笔记 ($0.03)"
curl -sS https://api.beatapi.io/v1/social-data/call \
  -H "Authorization: Bearer $BEATAPI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"action":"xiaohongshu.app_v2.search_notes","params":{"keyword":"露营咖啡机","page":1,"sort_type":"comment_descending"}}'
```

**`拉取笔记评论 ($0.03)`**

```bash title="拉取笔记评论 ($0.03)"
curl -sS https://api.beatapi.io/v1/social-data/call \
  -H "Authorization: Bearer $BEATAPI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"action":"xiaohongshu.app_v2.get_note_comments","params":{"note_id":"<note_id>","cursor":"","index":0,"pageArea":"UNFOLDED","sort_strategy":"latest_v2"}}'
```

### 搜索返回结构示例（2026-11-23 实测脱敏）

```json
{
  "object": "social_data.call",
  "status": "succeeded",
  "request_id": "202611260732156684925978268d9d6yOLdMCKV",
  "action": "xiaohongshu.app_v2.search_notes",
  "data": {
    "code": 0,
    "success": true,
    "page": 1,
    "next_page": 2,
    "search_id": "2eExampleSearchId",
    "data": {
      "items": [
        {
          "note": {
            "id": "6a9c5884000000002b002d95",
            "title": "示例咖啡机真实体验测评"
          }
        }
      ]
    }
  },
  "usage": {
    "billing_unit": "request",
    "quantity": 1,
    "price_usd": "0.03",
    "price_version": "sd_20cf7d377ad9"
  }
}
```

在 `xiaohongshu.app_v2.get_note_comments` 和小红书详情动作上，传入格式错误的 `note_id` 或无法解析的链接时，上游可能返回 HTTP 200 且 `data` 内带业务报错并仍会计费。调用前请先从搜索响应或有效分享链接提取真实 `note.id`（见 [小红书业务错误说明](/zh/faq/xiaohongshu-business-errors)）。

## 相关文档

* [解决小红书 461 报错](/zh/faq/xiaohongshu-461-status-code)
* [免登录小红书 MCP 方案](/zh/faq/xiaohongshu-mcp-without-login)
* [抓取小红书笔记评论](/zh/guides/xiaohongshu-note-comments)