# 内容搜索接口

> 12 个平台的 12 个接口，用同一个 Post 对象返回搜索结果。按关键词搜到的内容（视频、笔记、帖子或文章），结果来自平台自己的搜索，按页返回，每条带作者和互动数据。每次 $0.002 到 $0.02，各接口按自己的价格计费；失败的调用不扣费。

网页版：https://okdata.online/zh/roles/posts-search/

## 各平台接口

| 平台 | 接口 | 路径 | 每页 | 价格 |
|---|---|---|---|---|
| 抖音 | [抖音视频搜索](https://okdata.online/zh/apis/douyin/videos/search/) | `GET /v1/douyin/videos/search` | 20 | $0.02/次 · 每页约 20 条视频 |
| 小红书 | [小红书笔记搜索](https://okdata.online/zh/apis/xiaohongshu/notes/search/) | `GET /v1/xiaohongshu/notes/search` | 20 | $0.02/次 · 每页约 20 篇笔记 |
| B站 | [B站视频搜索](https://okdata.online/zh/apis/bilibili/videos/search/) | `GET /v1/bilibili/videos/search` | 20 | $0.002/次 · 每页约 20 条视频 |
| 微博 | [微博搜索](https://okdata.online/zh/apis/weibo/posts/search/) | `GET /v1/weibo/posts/search` | 10 | $0.002/次 · 每页约 10 条帖子 |
| TikTok | [TikTok 视频搜索](https://okdata.online/zh/apis/tiktok/videos/search/) | `GET /v1/tiktok/videos/search` | 30 | $0.002/次 · 每页约 30 条视频 |
| X（推特） | [X 帖子搜索](https://okdata.online/zh/apis/x/posts/search/) | `GET /v1/x/posts/search` | 20 | $0.002/次 · 每页约 20 条帖子 |
| YouTube | [YouTube 视频搜索](https://okdata.online/zh/apis/youtube/videos/search/) | `GET /v1/youtube/videos/search` | 20 | $0.004/次 · 每页约 20 条视频 |
| Reddit | [Reddit 帖子搜索](https://okdata.online/zh/apis/reddit/posts/search/) | `GET /v1/reddit/posts/search` | 25 | $0.004/次 · 每页约 25 条帖子 |
| 快手 | [快手视频搜索](https://okdata.online/zh/apis/kuaishou/videos/search/) | `GET /v1/kuaishou/videos/search` | 10 | $0.02/次 · 每页约 10 条视频 |
| 知乎 | [知乎内容搜索](https://okdata.online/zh/apis/zhihu/posts/search/) | `GET /v1/zhihu/posts/search` | 20 | $0.002/次 · 每页约 20 条帖子 |
| 微信视频号 | [视频号视频搜索](https://okdata.online/zh/apis/wechat_channels/videos/search/) | `GET /v1/wechat_channels/videos/search` | 10 | $0.02/次 · 每页约 10 条视频 |
| 微信搜一搜 | [微信搜一搜综合搜索](https://okdata.online/zh/apis/wechat/posts/search/) | `GET /v1/wechat/posts/search` | 20 | $0.02/次 · 每页约 20 条帖子 |

## 返回的对象：[Post](https://okdata.online/zh/docs/objects/post/)

上面每个接口返回的字段名和类型都一样。平台不展示的字段返回 null，并在 meta.unavailable 里注明。

| 字段 | 类型 | 含义 |
|---|---|---|
| `id` | `string` | 内容在平台上的 ID。 |
| `url` | `string` | 内容链接。 |
| `type` | `string` | 内容类型。 |
| `title` | `string \| null` | 标题（视频、笔记、文章才有）。 |
| `text` | `string` | 文案、正文或简介，纯文本；文章为 Markdown。 |
| `lang` | `string \| null` | 语言代码，平台给出或检测得到。 |
| `published_at` | `string \| null` | 发布时间，ISO 8601，UTC；只有数据源不给时间时为 null（wechat_mp.articles.metrics、wechat_channels.videos.metrics、youtube.channels.videos.list 取 Shorts 时），并列在 meta.unavailable 里。 |
| `author` | `AccountRef` | 发布者。 |
| `metrics` | `Metrics` | 抓取时的数据；平台不公开的为 null。 |
| `images` | `string[] \| null` | 图文内容的图片地址。 |
| `hashtags` | `string[] \| null` | 话题标签，不带 #。 |
| `ext` | `object` | 平台特有字段，只在 view=full 时返回。 |

## 两个平台上的同一个调用

参数一样、翻页方式一样、返回结构一样，只换路径。

```bash
# 抖音
curl -G "https://api.okdata.online/v1/douyin/videos/search" \
  -H "Authorization: Bearer $OKDATA_API_KEY" \
  --data-urlencode 'query=露营装备'

# 小红书
curl -G "https://api.okdata.online/v1/xiaohongshu/notes/search" \
  -H "Authorization: Bearer $OKDATA_API_KEY" \
  --data-urlencode 'query=防晒霜 推荐'
```

## 常见用途

- 每天看大家发了哪些提到你品牌或产品的内容。
- 动笔之前，先找出某个话题下表现最好的内容。
- 比较同一个关键词在抖音、小红书和 TikTok 上的表现。

## 常见问题

### 结果和 App 里搜到的一样吗？

结果来自平台自己的搜索，按你用 sort 选的顺序排，所以和 App 里接近。和 App 一样，隔几分钟搜两次，结果也可能有变化。

### 一个关键词最多能拿多少条？

用 cursor 一页页翻，直到 page.has_more 为 false。每个平台都有翻到底的时候，能翻多深因平台和关键词而异。每一页是一次调用。

### 能只搜最近发布的吗？

大多数接口支持 sort=latest。有些还能按发布时间筛选，比如 Reddit、快手和视频号；具体参数见各接口页。

## 其他数据类型

- [评论接口](https://okdata.online/zh/roles/posts-comments-list/)
- [热榜接口](https://okdata.online/zh/roles/trends-list/)
- [评论回复接口](https://okdata.online/zh/roles/comments-replies-list/)
- [话题内容接口](https://okdata.online/zh/roles/topics-posts-list/)
- [账号信息接口](https://okdata.online/zh/roles/accounts-get/)
- [账号作品列表接口](https://okdata.online/zh/roles/accounts-posts-list/)
- [内容详情接口](https://okdata.online/zh/roles/posts-get/)
- [热门内容接口](https://okdata.online/zh/roles/posts-trending/)
- [账号搜索接口](https://okdata.online/zh/roles/accounts-search/)
- [内容数据接口](https://okdata.online/zh/roles/posts-metrics/)
- [社区帖子接口](https://okdata.online/zh/roles/communities-posts-list/)
- [广告详情接口](https://okdata.online/zh/roles/ads-get/)
- [广告主广告列表接口](https://okdata.online/zh/roles/advertisers-ads-list/)
- [广告搜索接口](https://okdata.online/zh/roles/ads-search/)
- [字幕接口](https://okdata.online/zh/roles/transcripts-get/)
- [粉丝列表接口](https://okdata.online/zh/roles/accounts-followers-list/)
- [商品详情接口](https://okdata.online/zh/roles/products-get/)
- [商品评价接口](https://okdata.online/zh/roles/products-reviews-list/)
- [商品搜索接口](https://okdata.online/zh/roles/products-search/)
- [达人搜索接口](https://okdata.online/zh/roles/creators-search/)
- [达人详情接口](https://okdata.online/zh/roles/creators-get/)
- [达人粉丝画像接口](https://okdata.online/zh/roles/creators-audience-get/)
