# 小紅書圖片搜尋 API

> 按關鍵詞搜圖片，每條是一張圖片和它所在的筆記：原圖、筆記標題、正文、作者、點贊、評論和收藏。這裡沒有分享數，筆記詳情裡有。

網頁版：https://okdata.online/zh/apis/xiaohongshu/images/search/

- **介面**：`GET /v1/xiaohongshu/images/search`
- **ID**：`xiaohongshu.images.search`
- **價格**：$0.02/次 · 每頁約 20 條帖子
- **返回**：一頁約 20 條帖子（`data.items`，Post 物件）
- **狀態**：預覽
- **適合**：內容調研、熱點研究

## 價格

每次呼叫 $0.02，返回一頁，約 20 條帖子。抓 1,000 條帖子大約要 50 次呼叫，合計 $1.00。每翻一頁是一次單獨的呼叫。請求到了平台的呼叫，返回為空、查不到或出錯也照常計費；還沒請求到平台就被攔下的不扣費。

## 引數

| 引數名 | 型別 | 必填 | 預設值 | 說明 |
|---|---|---|---|---|
| `query` | string | 是 |  | 關鍵詞，和在平台搜尋框裡輸入的一樣。（例：`耐克`） |
| `cursor` | string | 否 |  | 上一次返回的 page.next_cursor，原樣傳回。每翻一頁都是一次單獨的呼叫。 |
| `view` | string: brief / compact / standard / full | 否 | `standard` | 返回多少欄位。brief：只給 ID、標題、正文前 100 字、連結、時間和主要數字，適合先掃一遍列表，再按 ID 取詳情；compact 去掉空欄位、長正文截到 500 字；full 會在 ext 裡帶上平台特有欄位。 |
| `fields` | string[] | 否 |  | 只保留這些欄位，按路徑寫（如 author.name），用來省 token。放在查詢引數裡時用逗號分隔。 |

cursor、view、fields 的用法見 [請求說明](https://okdata.online/zh/docs/requests/)。

## 返回欄位

每一條都是一個 [Post](https://okdata.online/zh/docs/objects/post/)。

| 欄位 | 型別 | 說明 |
|---|---|---|
| `id` | string | 內容在平台上的 ID。 |
| `url` | string | 內容連結。 |
| `type` | string | 內容型別。 |
| `title` | string \| null | 標題（影片、筆記、文章才有）。 |
| `text` | string | 文案、正文或簡介，純文本；文章為 Markdown。 |
| `lang` | string \| null | 語言程式碼，平台給出或檢測得到。 |
| `published_at` | string \| null | 釋出時間，ISO 8601，UTC；只有平台不給時間（wechat_mp.articles.metrics、wechat_channels.videos.metrics、youtube.channels.videos.list 取 Shorts 時）或某次回答裡缺了時間（youtube.videos.get 偶爾會）時為 null，並列在 meta.unavailable 裡。不會是空字串。 |
| `author` | AccountRef | 釋出者。 |
| `metrics` | Metrics | 抓取時的資料；平台不公開的為 null。 |
| `images` | string[] \| null | 圖文內容的圖片地址。 |
| `hashtags` | string[] \| null | 話題標籤，不帶 #。 |
| `ext` | object | 平台特有欄位，只在 view=full 時返回。 |

## 請求示例

### cURL

```bash
curl -G "https://api.okdata.online/v1/xiaohongshu/images/search" \
  -H "Authorization: Bearer $OKDATA_API_KEY" \
  --data-urlencode 'query=耐克'
```

### Python

```python
import os
import requests

resp = requests.get(
    "https://api.okdata.online/v1/xiaohongshu/images/search",
    headers={"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"},
    params={"query": "耐克"},
    timeout=60,
)
body = resp.json()
if body["code"] != "ok":
    raise RuntimeError(f"{body['code']}: {body['message']} (charged: {body['charged']})")

for row in body["data"]["items"]:
    print(row["id"], row["metrics"]["likes"], row["text"][:60])
print("cost: $" + body["meta"]["billing"]["amount"])
```

### TypeScript

```ts
const url = new URL('https://api.okdata.online/v1/xiaohongshu/images/search');
url.searchParams.set('query', "耐克");

const res = await fetch(url, {
  headers: {
    Authorization: `Bearer ${process.env.OKDATA_API_KEY}`,
  },
});
const body = await res.json();
if (body.code !== 'ok') throw new Error(`${body.code}: ${body.message}`);

for (const row of body.data.items) {
  console.log(row.id, row.metrics.likes, row.text.slice(0, 60));
}
console.log('cost: $' + body.meta.billing.amount);
```

### MCP

```json
{
  "name": "call",
  "arguments": {
    "capability": "xiaohongshu.images.search",
    "query": "耐克"
  }
}
```

或者對接好 MCP 的智慧體直接說：

> 用「小紅書圖片搜尋」找出點贊最多的五條內容，附連結。

## 返回示例

```json
{
  "code": "ok",
  "request_id": "0f6c2a8e-4b1d-4e0a-9a51-3c7d2b9e1f20",
  "data": {
    "items": [
      {
        "id": "6731f0a2000000001b02c3d4",
        "url": "https://www.xiaohongshu.com/explore/6731f0a2000000001b02c3d4",
        "type": "image",
        "title": "油皮夏天防曬怎麼選｜實測 6 款",
        "text": "連續兩週通勤實測，按清爽度和防曬力排了個序，第 3 款意外好用。",
        "lang": "zh",
        "published_at": "2026-11-02T09:30:00Z",
        "author": {
          "id": "5f1234567890abcdef123456",
          "username": null,
          "name": "通勤護膚筆記",
          "avatar_url": "https://cdn.example.com/avatar/trailkit.jpg",
          "followers": 46200,
          "verified": true
        },
        "metrics": {
          "views": null,
          "likes": 48200,
          "comments": 1312,
          "shares": 2210,
          "favorites": 9650,
          "reposts": null
        },
        "images": [
          "https://sns-img.example.com/6731f0a2/1.jpg",
          "https://sns-img.example.com/6731f0a2/2.jpg"
        ],
        "hashtags": [
          "防曬",
          "油皮"
        ]
      }
    ]
  },
  "page": {
    "next_cursor": "c1.k3Vq9TzR0bYw2LmXe8NdPa",
    "cursor_expires_at": "2026-11-12T08:00:00Z",
    "has_more": true,
    "returned": 1
  },
  "warnings": [],
  "meta": {
    "capability": "xiaohongshu.images.search",
    "result_status": "complete",
    "billing": {
      "amount": "0.02",
      "currency": "USD",
      "balance_after": "9.98"
    },
    "unavailable": {
      "metrics.views": "platform",
      "metrics.reposts": "platform"
    },
    "cached": false,
    "replayed": false,
    "fetched_at": "2026-11-11T08:00:00Z"
  }
}
```

## 錯誤

所有錯誤同一種結構：code、request_id、message 和 message_zh（每個 code 一句固定的話）、charged、retry、retry_after_seconds、param 和 docs_url，具體問題寫在 problems 裡。請求到了平台的調用出錯（查不到、平台失敗或超時）時，按這個介面的價格計一次費，charged 為 true，並給出 amount；引數錯誤這類還沒請求到平台的錯誤不扣費。只有 settlement_unknown 的扣費結果要查詢後才知道。完整列表：https://okdata.online/zh/docs/errors/

## 常見問題

### 小紅書圖片搜尋介面多少錢？

每次呼叫 $0.02，返回一頁，約 20 條帖子。抓 1,000 條帖子大約要 50 次呼叫，合計 $1.00。每翻一頁是一次單獨的呼叫。請求到了平台的呼叫，返回為空、查不到或出錯也照常計費；還沒請求到平台就被攔下的不扣費。

### 怎麼翻頁？

把返回裡的 page.next_cursor 原樣作為 cursor 引數傳回去。page.has_more 為 false 時就沒有下一頁了。每一頁都是一次 $0.02 的呼叫。

### 需要小紅書帳號、Cookie 或掃碼登入嗎？

不需要。只要帶上 okdata 的 API key。返回的是小紅書上的公開資料，不會用到你自己的小紅書帳號。

### 呼叫失敗會扣費嗎？

請求到了平台就會扣一次：返回為空、查不到、平台出錯或超時，都按一次呼叫計費（按條計價的按 1 條），錯誤裡 charged 為 true，並給出 amount。引數錯誤、餘額不足這類還沒請求到平台就被攔下的不扣費。

### 小紅書不展示某個欄位怎麼辦？

這個欄位會是 null，meta.unavailable 裡會列出它和原因：platform（平台本來就不展示）或 capability（我們暫時取不到）。

## 小紅書的其他介面

- [小紅書筆記搜尋](https://okdata.online/zh/apis/xiaohongshu/notes/search/)：$0.035/次 · 每頁約 20 篇筆記
- [小紅書筆記詳情](https://okdata.online/zh/apis/xiaohongshu/notes/get/)：$0.035/次
- [小紅書筆記評論](https://okdata.online/zh/apis/xiaohongshu/notes/comments/list/)：$0.035/次 · 每頁約 10 條評論
- [小紅書博主資訊](https://okdata.online/zh/apis/xiaohongshu/users/get/)：$0.02/次
- [小紅書博主筆記列表](https://okdata.online/zh/apis/xiaohongshu/users/notes/list/)：$0.03/次 · 每頁約 20 篇筆記
- [小紅書熱點話題](https://okdata.online/zh/apis/xiaohongshu/trends/list/)：$0.03/次 · 每頁約 20 條榜單
- [小紅書蒲公英達人搜尋](https://okdata.online/zh/apis/xiaohongshu/pgy/creators/search/)：$0.04/次 · 每頁約 20 位達人
- [小紅書蒲公英達人詳情](https://okdata.online/zh/apis/xiaohongshu/pgy/creators/get/)：$0.04/次
- [小紅書商城商品搜尋](https://okdata.online/zh/apis/xiaohongshu/shop/products/search/)：$0.02/次 · 每頁約 20 個商品
- [小紅書商城商品評價](https://okdata.online/zh/apis/xiaohongshu/shop/products/reviews/list/)：$0.02/次 · 每頁約 12 條評價
- [小紅書評論回覆](https://okdata.online/zh/apis/xiaohongshu/comments/replies/list/)：$0.03/次 · 每頁約 5 條評論
- [小紅書話題筆記](https://okdata.online/zh/apis/xiaohongshu/topics/notes/list/)：$0.03/次 · 每頁約 10 篇筆記
- [小紅書話題詳情](https://okdata.online/zh/apis/xiaohongshu/topics/get/)：$0.02/次
- [小紅書帳號搜尋](https://okdata.online/zh/apis/xiaohongshu/users/search/)：$0.03/次 · 每頁約 20 個帳號
- [小紅書商城商品詳情](https://okdata.online/zh/apis/xiaohongshu/shop/products/get/)：$0.02/次
- [小紅書搜尋聯想詞](https://okdata.online/zh/apis/xiaohongshu/keywords/related/)：$0.02/次 · 每頁約 10 條結果
- [小紅書影片筆記詳情（影片地址）](https://okdata.online/zh/apis/xiaohongshu/videos/get/)：$0.035/次
- [小紅書蒲公英關鍵詞搜尋指數](https://okdata.online/zh/apis/xiaohongshu/pgy/keywords/history/)：$0.04/次
- [小紅書蒲公英關聯詞](https://okdata.online/zh/apis/xiaohongshu/pgy/keywords/related/)：$0.04/次 · 每頁約 98 條結果
- [小紅書蒲公英達人粉絲畫像](https://okdata.online/zh/apis/xiaohongshu/pgy/creators/audience/get/)：$0.04/次
- [小紅書蒲公英達人資料表現](https://okdata.online/zh/apis/xiaohongshu/pgy/creators/metrics/)：$0.04/次
- [小紅書蒲公英達人筆記](https://okdata.online/zh/apis/xiaohongshu/pgy/creators/notes/list/)：$0.04/次 · 每頁約 8 篇筆記
- [小紅書蒲公英達人粉絲趨勢](https://okdata.online/zh/apis/xiaohongshu/pgy/creators/followers/history/)：$0.04/次
- [小紅書蒲公英相似達人](https://okdata.online/zh/apis/xiaohongshu/pgy/creators/related/)：$0.04/次 · 每頁約 4 位達人
- [小紅書蒲公英內容廣場熱門筆記](https://okdata.online/zh/apis/xiaohongshu/pgy/notes/trending/)：$0.04/次 · 每頁約 34 篇筆記
- [小紅書蒲公英達人合作成本概覽](https://okdata.online/zh/apis/xiaohongshu/pgy/creators/costs/metrics/)：$0.04/次
- [小紅書蒲公英達人粉絲概覽](https://okdata.online/zh/apis/xiaohongshu/pgy/creators/followers/metrics/)：$0.04/次
- [小紅書蒲公英達人核心資料趨勢](https://okdata.online/zh/apis/xiaohongshu/pgy/creators/costs/history/)：$0.04/次
- [小紅書蒲公英筆記資料](https://okdata.online/zh/apis/xiaohongshu/pgy/notes/get/)：$0.04/次
- [小紅書影片轉文字](https://okdata.online/zh/apis/xiaohongshu/videos/transcript/get/)：$0.084/次
- [小紅書圖文筆記圖片取文字](https://okdata.online/zh/apis/xiaohongshu/notes/text/get/)：$0.048/次
- [小紅書影片畫面文字](https://okdata.online/zh/apis/xiaohongshu/videos/screen_text/get/)：$0.052/次
- [小紅書圖文筆記圖片地址](https://okdata.online/zh/apis/xiaohongshu/notes/media/get/)：$0.043/次
- [小紅書影片筆記檔案地址](https://okdata.online/zh/apis/xiaohongshu/videos/media/get/)：$0.043/次

## 概要

- **簡稱**：小紅書圖片搜尋
- **英文名**：Xiaohongshu image search API
- **也叫**：小紅書搜圖、搜小紅書圖片
- **分類**：[社交媒體](https://okdata.online/zh/categories/social/)
- **狀態**：預覽。還可能調整，改動會提前公告。
- **價格**：$0.02（約 ¥0.14） / 次 · 引數錯誤不扣費
- **返回**：每頁約 20 條帖子，帶翻下一頁的游標
- **調用出錯時**：照常計一次費。出錯時我們這邊先自動重試。請求到了平台的呼叫，出錯也按一次計費；引數錯誤不扣費。

## 什麼時候收費

- 返回了資料：$0.02，每次呼叫收一次
- 引數不合法、餘額不足、介面暫停：不收費

| 情況 | 收費 |
|---|---|
| 每翻一頁 | 另算一次呼叫：$0.02 |
| 單次最高扣費 | $0.02 |
| 空結果 | $0.02 |
| 平台出錯或超時 | $0.02 |
| 引數不合法、餘額不足、介面暫停 | 不收費 |
| 24 小時內帶同一個 Idempotency-Key 重發 | 直接返回儲存的結果，不扣費 |

請求到了平台的呼叫，返回為空、查不到或出錯也照常計費，收 $0.02；引數錯誤這類還沒請求平台就被攔下的不扣費。

價格取自價目表版本 fb99dc8a88674793。 [這個平台的全部價格](https://okdata.online/zh/pricing/xiaohongshu/)

- 新帳號送 $0.20 試用額度，不用綁卡：夠調這個介面 10 次。
- 抓 1,000 條帖子約要 50 次呼叫，合計 $1.00。

## 已知限制

- 每頁約 20 條帖子，條數由平台決定，沒有每頁條數引數。
- 翻下一頁時把 `page.next_cursor` 作為 `cursor` 傳回。游標 24 小時內有效。`page.has_more` 為 false 時就沒有下一頁了。

## 各檢視返回的欄位

“檢視”一列是欄位最早出現的 `view`：`compact` 只返回 compact 欄位，`standard` 再加上 standard 欄位，`full` 返回全部。預設是 `standard`。

- `compact`：`id`, `url`, `type`, `title`, `text`, `published_at`, `author`, `metrics`
- `standard`：`lang`, `images`, `hashtags`
- `full`：`ext`

## 這個介面給不了的

- `metrics.views`：平台不展示（為 null，列在 meta.unavailable 裡）
- `metrics.reposts`：平台不展示（為 null，列在 meta.unavailable 裡）

## 這個介面的常見報錯

| 狀態碼 | 程式碼 | 含義 | 是否扣費 | 能否重試 |
|---|---|---|---|---|
| 400 | `invalid_params` | 引數缺失、型別或取值不對，或者請求方法不對。problems 列出每一處問題，param 是第一個出錯的引數。 | 否 | 修正後重試 |
| 400 | `cursor_mismatch` | cursor 發到了別的介面，或者引數和它所在那一頁不一樣（view 和 fields 可以變）。 | 否 | 修正後重試 |
| 401 | `unauthorized` | Key 缺失、格式不對、已撤銷、已停用或已過期（知道原因時 reason 會寫明）。 | 否 | 不要重試 |
| 402 | `insufficient_balance` | 餘額（available）不夠這次呼叫的最高費用（required）。 | 否 | 修正後重試 |
| 410 | `cursor_expired` | cursor 超過了這個介面的有效期（page.cursor_expires_at 寫了到期時間）。 | 否 | 不要重試 |
| 429 | `rate_limited` | 帳號這一分鐘請求太多（reason: rate），或同時進行的呼叫太多（reason: concurrency）。 | 否 | 可以重試 |
| 500 | `settlement_unknown` | 資料已返回，但沒能確認是否扣費。 | 查詢後才知道 | 用同一個 Idempotency-Key 重試 |
| 502 | `fetch_failed` | 我們這邊自動重試後，這次請求仍然失敗了。如果請求到了平台、且這次請求產生了費用，就按介面價格計一次費（charged 為 true，並給出 amount）；否則不計費。 | 請求到了平台就扣一次 | 可以重試 |
| 503 | `capability_paused` | 這個介面暫時停用了，這次沒有執行。 | 否 | 可以重試 |
| 504 | `timeout` | 資料沒有及時返回。如果請求到了平台、且這次請求產生了費用，就按介面價格計一次費（charged 為 true，並給出 amount）；否則預扣退回。 | 請求到了平台就扣一次 | 可以重試 |

[全部錯誤碼](https://okdata.online/zh/docs/errors/)

## 在你的 AI 裡用

> 先讀 https://okdata.online/zh/apis/xiaohongshu/images/search.md，再用 okdata 幫我調這個介面，key 在環境變數 OKDATA_API_KEY 裡。用「小紅書圖片搜尋」找出點贊最多的五條內容，附連結。

## 小紅書的介面分組

- [小紅書蒲公英 API](https://okdata.online/zh/apis/xiaohongshu/pgy/)：小紅書蒲公英達人搜尋 $0.04、小紅書蒲公英達人詳情 $0.04、小紅書蒲公英關鍵詞搜尋指數 $0.04、小紅書蒲公英關聯詞 $0.04、小紅書蒲公英達人粉絲畫像 $0.04、小紅書蒲公英達人資料表現 $0.04、小紅書蒲公英達人筆記 $0.04、小紅書蒲公英達人粉絲趨勢 $0.04、小紅書蒲公英相似達人 $0.04、小紅書蒲公英內容廣場熱門筆記 $0.04、小紅書蒲公英達人合作成本概覽 $0.04、小紅書蒲公英達人粉絲概覽 $0.04、小紅書蒲公英達人核心資料趨勢 $0.04、小紅書蒲公英筆記資料 $0.04
- [小紅書商城 API](https://okdata.online/zh/apis/xiaohongshu/shop/)：小紅書商城商品搜尋 $0.02、小紅書商城商品評價 $0.02、小紅書商城商品詳情 $0.02
