# search

POST /v1/search 是“搜索”动作：按关键词找内容或账号。目前在 16 个平台上开放（TikTok、Instagram、X、Reddit、YouTube、LinkedIn 等），平台是请求里的一个参数。每次调用 2 到 12 积分，因平台而异；失败的调用不扣。

- 页面：https://socialtoai.com/zh/docs/api/search/
- 最近更新：2026-10-17

- POST: `https://api.socialtoai.com/v1/search`

## 请求

请求体是 JSON。下面这几项每个动作都一样，其余的参数因平台而异，见后文。

| 名称 | 类型 | 位置 | 必填 | 说明 |
| --- | --- | --- | --- | --- |
| `platform` | string | 请求体 | 是 | 要读的平台，取这个动作已开放的平台之一。 |
| `max_cost_credits` | integer | 请求体 | 否 | 这次调用最多花多少积分。超出时免费拒绝，并在返回里给出报价。 |
| `Idempotency-Key` | string | 请求头 | 否 | 1 到 255 个可见 ASCII 字符。同一个键加同样的参数会返回第一次的结果，不会重复扣费。 |

## 平台与积分

每个平台收的参数不同。平台自己的页面上有完整的参数表、字段表和可以改的请求。

| 平台 | 价格键 | 积分 | 必填 | 可选 | 每页 |
| --- | --- | --- | --- | --- | --- |
| [TikTok](https://socialtoai.com/zh/tiktok-search-api.md) | `tiktok.search` | 2 | `query` | `sort`、`published_within` | 30 |
| [Instagram](https://socialtoai.com/zh/instagram-search-api.md) | `instagram.search:user` | 3 | `query`、`type=user` | – | 50 |
| [X](https://socialtoai.com/zh/x-search-api.md) | `x.search` | 2 | `query` | `sort` | 20 |
| [Reddit](https://socialtoai.com/zh/reddit-search-api.md) | `reddit.search` | 2 | `query` | `sort`、`published_within` | 25 |
| [YouTube](https://socialtoai.com/zh/youtube-search-api.md) | `youtube.search` | 2 | `query` | `sort`、`published_within` | 100 |
| [LinkedIn](https://socialtoai.com/zh/linkedin-search-api.md) | `linkedin.search` | 2 | `query` | `published_within` | 10 |
| [Threads](https://socialtoai.com/zh/threads-search-api.md) | `threads.search` | 2 | `query` | `since`、`until` | 20 |
| [Pinterest](https://socialtoai.com/zh/pinterest-search-api.md) | `pinterest.search` | 2 | `query` | – | 50 |
| [小红书](https://socialtoai.com/zh/xiaohongshu-search-api.md) | `xiaohongshu.search` | 12 | `query` | `sort` | 20 |
| [抖音](https://socialtoai.com/zh/douyin-search-api.md) | `douyin.search` | 12 | `query` | `sort`、`published_within` | 20 |
| [微博](https://socialtoai.com/zh/weibo-search-api.md) | `weibo.search` | 2 | `query` | – | 20 |
| [公众号](https://socialtoai.com/zh/wechat-search-api.md) | `wechat.search` | 12 | `query` | `sort`、`published_within` | 30 |
| [B 站](https://socialtoai.com/zh/bilibili-search-api.md) | `bilibili.search` | 2 | `query` | `sort` | 20 |
| [知乎](https://socialtoai.com/zh/zhihu-search-api.md) | `zhihu.search` | 2 | `query` | `type`、`sort` | 20 |
| [快手](https://socialtoai.com/zh/kuaishou-search-api.md) | `kuaishou.search` | 12 | `query` | – | 20 |
| [视频号](https://socialtoai.com/zh/wechat-channels-search-api.md) | `wechat_channels.search` | 12 | `query` | `sort`、`published_within` | 20 |

有些平台的这个动作还有另一种取值，由某个参数选中，单独计价：

| 平台 | 价格键 | 积分 | 由什么选中 |
| --- | --- | --- | --- |
| TikTok | `tiktok.search:user` | 2 | `type=user` |
| X | `x.search:latest` | 2 | `sort=latest` |
| X | `x.search:user` | 5 | `type=user` |
| 小红书 | `xiaohongshu.search:user` | 12 | `type=user` |
| 小红书 | `xiaohongshu.search:image` | 12 | `type=image` |
| 抖音 | `douyin.search:user` | 2 | `type=user` |
| 微博 | `weibo.search:user` | 2 | `type=user` |
| 知乎 | `zhihu.search:user` | 2 | `type=user` |

## 参数

| 名称 | 类型 | 说明 | 哪些平台收 |
| --- | --- | --- | --- |
| `query` | string | 搜索词 | 全部 |
| `sort` | string | 按相关度、点赞数或发布时间排取值因平台而异：`relevance`、`popular`、`latest` | TikTok、X、Reddit、YouTube、小红书、抖音、公众号、B 站、知乎和视频号 |
| `published_within` | string | 只要最近这段时间发布的取值因平台而异：`day`、`week`、`month`、`half_year`、`year` | TikTok、Reddit、YouTube、LinkedIn、抖音、公众号和视频号 |
| `since` | datetime | 发布日期不早于这一天（按 UTC 日期筛，不看时分秒） | Threads |
| `until` | datetime | 发布日期不晚于这一天（按 UTC 日期筛，不看时分秒） | Threads |
| `type` | string | 只要回答，或只要文章；不写则两种都有取值因平台而异：`answer`、`article` | 知乎 |

## 示例

TikTok：按关键词找视频：正文、作者、点赞数、评论数、播放或阅读数和发布时间。

**cURL**

```
curl https://api.socialtoai.com/v1/search \
  -H "Authorization: Bearer $SOCIALTOAI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "tiktok",
    "query": "space station"
  }'
```

**Python**

```
import os
import requests

response = requests.post(
    "https://api.socialtoai.com/v1/search",
    headers={"Authorization": f"Bearer {os.environ['SOCIALTOAI_KEY']}"},
    json={
        "platform": "tiktok",
        "query": "space station",
    },
)
print(response.json())
```

**返回** (200 OK, 2 积分)

```
{
  "request_id": "req_00000000-0000-4000-8000-000000000001",
  "schema_version": "v1",
  "fetched_at": "2026-10-12T19:17:24.000Z",
  "action": "search",
  "platform": "tiktok",
  "status": "ok",
  "items": [
    {
      "platform": "tiktok",
      "id": "…",
      "ref": "…",
      "approx": [],
      "type": "content",
      "url": "https://example.com/…",
      "format": "video",
      "title": null,
      "text": "…",
      "published_at": "2026-10-11T23:17:34.000Z",
      "author": {
        "id": "…",
        "username": "…",
        "name": "…",
        "verified": null,
        "followers": 92601
      },
      "metrics": {
        "likes": 353,
        "comments": 11,
        "shares": 19,
        "collects": 40,
        "views": 7561,
        "reposts": null
      },
      "images": null,
      "hashtags": ["…", "…"],
      "is_pinned": null
    }
  ],
  "unavailable": ["title", "author.verified", "metrics.reposts", "images", "is_pinned"],
  "page": {
    "has_more": true,
    "cursor": "cur_…",
    "cursor_expires_at": "2026-10-12T19:47:24.000Z"
  },
  "warnings": [],
  "applied_params": {
    "query": "space station"
  },
  "cost_credits": 2,
  "billing": {
    "cost_credits": 2,
    "balance_credits": 98,
    "today_spend_credits": 2,
    "daily_limit_credits": null,
    "daily_remaining_credits": null,
    "display": "本次 2 积分，余额 98 积分"
  },
  "replayed": false
}
```

_示例数据：名字、链接和正文已换成占位符。_

## 返回什么

返回[外层结构](https://socialtoai.com/zh/docs/api/response.md)，`items` 里是 [`content`](https://socialtoai.com/zh/docs/api/response.md)、[`account`](https://socialtoai.com/zh/docs/api/response.md) 对象。一次调用返回一页，最多 30 条；每一页是一次调用。cursor 最长 30 分钟内有效。

失败的调用是 0 积分，并说明原因，见[错误](https://socialtoai.com/zh/docs/api/errors.md)。
