# 微博 在用户微博里搜索 API (weibo.user_post_search)

- Canonical page: https://everyinfra.com/weibo-api/user_post_search
- Endpoint: POST /api/v1/social with {"platform": "weibo", "action": "user_post_search", "params": {...}}
- Price: $0.000806 per call ($0.81 per 1,000 requests); failed and empty results are not charged
- Returns: list, one page of up to 50 per call; the number of rows varies from page to page and a short page is not the end (limit is ignored; pass the top-level next_page_token from the response as page_token for the next page; no next_page_token means the end)
- 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

微博在用户微博里搜索按 `user_id` 和 `keyword`，在这个用户最近 12 个月发的微博里找含关键词的内容，每条带正文、发布时间、发布设备 `device`、转评赞数、图片和视频链接，以及是否为转发、是否长微博。它回答「这个人有没有、在什么时候谈过这件事」，适合公关核查一个账号的历史表态、记者找某位博主对某个话题的原话，或品牌查达人是否提过竞品。每页最多 50 条，比用户内容那一页的 20 条多。

`user_id` 是数字 UID，也可以传带 /u/ 加数字 UID 的主页链接，不收昵称。结果分页返回，用 `page_token` 翻页。每页条数不固定，短页不代表到底；`limit` 照收但不起作用。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| user_id | not declared | yes | not declared | 微博数字 UID，也可传含 /u/数字UID 的主页链接；不收昵称（先用 user_search 按昵称找到 user_id）。 |
| keyword | not declared | yes | not declared | 在这个用户最近 12 个月发的微博里搜的关键词，例如 发布会。 |
| page_token | not declared | no | not declared | 翻页令牌。第一页不传；之后把上一页响应里的 next_page_token 原样传回取下一页，其余参数不变。每页最多 50 条，每页算一次调用；翻到底时响应里没有 next_page_token。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在原平台上的可访问链接。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| device | 发布设备（如「iPhone客户端」）。 |
| repost_count | 转发数（区别于引用转发）。null 表示不公开。 |
| comment_count | 评论数。null 表示不公开，不等于 0。 |
| like_count | 点赞数。null 表示该平台或该接口不公开此数据，不等于 0。 |
| is_repost | 是否为转发。 |
| is_long_text | 是不是长微博（post_detail / user_posts）。user_posts 上长微博的 text 只有开头一段（约 140 字）。 |
| author_id | 作者在原平台的唯一 ID。 |
| author_name | 作者昵称（显示名）。 |
| author_verified | 作者是否加 V。 |
| author_avatar_url | 作者头像。 |
| image_urls | 图片列表；不带图的微博没有。 |
| video_url | 视频链接；不是视频微博时没有。 |
| duration_sec | 视频时长（秒，post_detail / user_posts 的视频微博）。 |
| duration_seconds | 时长，单位秒。非视频/音频内容为 null。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |
| next_page_token | 翻页令牌（user_search、user_posts、topic_search、user_post_search）：作为下一次请求的 page_token 原样传回取下一页；同一页每行的值相同，响应顶层也有同一个 next_page_token。没有该字段即到底。 |

## 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": "weibo",
  "action": "user_post_search",
  "params": {
    "user_id": "1749127163",
    "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": "weibo",
        "action": "user_post_search",
        "params": {
            "user_id": "1749127163",
            "keyword": "科技",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

No real sample for these example parameters yet: structure only, every value is a placeholder (…).

```text
{
  "id": "req_…",
  "platform": "weibo",
  "action": "user_post_search",
  "results": [
    {
      "id": …,
      "url": …,
      "text": …,
      "posted_at": …,
      "device": …,
      "repost_count": …,
      "comment_count": …,
      "like_count": …,
      "is_repost": …,
      "is_long_text": …,
      "author_id": …,
      "author_name": …,
      "author_verified": …,
      "author_avatar_url": …,
      "image_urls": …,
      "video_url": …,
      "duration_sec": …,
      "duration_seconds": …,
      "platform": …,
      "next_page_token": …
    }
  ],
  "next_page_token": …,
  "pagination": { … },
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 能搜一年以前的微博吗？

不能。这里的搜索范围是这个用户最近 12 个月发的微博；更早的内容可以试着用用户内容逐页往回读，再在本地按关键词筛。关键词是在这 12 个月里搜的，没有结果只代表这个窗口里没有，不代表这个人从没提过。往回读时，用户内容那一页没有关键词参数，只能在本地筛，每页最多 20 条。`posted_at` 是 ISO 8601 的 UTC 时间，核对发布时间前先换算成本地时区。

### 在用户微博里搜索和用户内容有什么区别？

用户内容按时间顺序列出一个账号的微博，可以按原创、视频、图片筛选；这里只返回含关键词的微博，适合目标明确的核查。只想找某件事的相关发言时，用这里省掉逐页翻找的调用。这一页没有这类筛选参数，要区分就看结果里的 `is_repost`、`video_url` 和 `image_urls`：`is_repost` 为真是转发，视频微博才有 `video_url`，不带图的微博没有 `image_urls`。

### 不知道博主的 UID 怎么办？

先用微博的账号搜索按昵称找到这个人，结果里的 `user_id` 就是数字 UID；也可以打开他的主页，链接里 /u/ 后面那串数字就是。拿到 `user_id` 之后，可以先在用户内容里看这个账号最近发什么，再用关键词缩小范围。示例里 `user_id` 填 1749127163、`keyword` 填 科技，可以照这个写法试一次。搜到的每条都带 `id`，需要全文或阅读数时，把它传给内容详情。

## Also

- Capability catalog (no key): https://api.everyinfra.com/api/v1/social/catalog?platform=weibo
- OpenAPI: https://everyinfra.com/openapi.json · Agents guide: https://everyinfra.com/agents.md
