# 如何用接口查微信搜一搜的结果

用 1 个接口：微信搜一搜综合搜索。下面的示例一共 2 次调用，合计 $0.0400；失败的调用不收费。

拿到微信搜一搜里一个词的搜索结果，一页一页往下翻：公众号文章和视频号作品混在一起，每条有标题或文案、来源账号名称和发布时间；文章带链接，视频带点赞和收藏数。

## 一步一步做

### 第 1 步：微信搜一搜综合搜索

按 `query` 搜。每条的 `type` 说明是文章还是视频。`sort` 可以按相关、最新或最热排，`published_within` 只要最近一段时间的。翻下一页时把 `page.next_cursor` 作为 `cursor` 传进去，直到 `page.has_more` 为 false。（[微信搜一搜综合搜索](https://dataxapi.com/zh/apis/wechat/posts/search/)，$0.0200 / 一次）

cURL

```bash
curl -G "https://api.dataxapi.com/v1/wechat/posts/search" \
  --data-urlencode "query=咖啡店开业" \
  -H "Authorization: Bearer $DATAXAPI_API_KEY"
```

Python

```python
# pip install dataxapi
from dataxapi import DataXAPI

dx = DataXAPI()  # reads DATAXAPI_API_KEY
result = dx.wechat.posts.search(query="咖啡店开业")
print(result["data"]["items"])
```

TypeScript

```typescript
// npm i @dataxapi/sdk
import { DataXAPI } from "@dataxapi/sdk";

const dx = new DataXAPI(); // reads DATAXAPI_API_KEY
const result = await dx.wechat.posts.search({ query: "咖啡店开业" });
console.log(result.data.items);
```

命令行

```bash
dataxapi call wechat.posts.search 'query=咖啡店开业'
```

录制的返回：取自 2026-10-17 10:16 UTC 录下的真实返回。名字、正文和编号是示例，链接也是，都不是录到的原文（页面不展示任何人的个人信息）；数字是原样。长列表做了截断。请求号、游标和余额是示意。

```jsonc
{
  "code": "ok",
  "request_id": "f99e115c-779f-40c2-8f31-aa264bce80dd",
  "data": {
    "items": [
      {
        "id": "1565947629032858",
        "url": null,
        "type": "video",
        "title": null,
        "text": "咖啡店开业｜第一次尝试就爱上了，清单放评论区",
        "published_at": "2026-10-15T06:55:50.000Z",
        "author": {
          "name": "橘子汽水不加冰",
          "avatar_url": "https://wx.qlogo.cn/mmhead/G9OFE9nvQizvdtoFhYPbPgJwNlPo1GOTzMZ7Yb1e/132"
        },
        "metrics": { "likes": 1, "favorites": 3 }
      },
      // … 另有 19 条
    ]
  },
  "page": {
    "next_cursor": "c1.qgwIcUU3N03dRsj5WCHQWiriygBg_3bRP0gIll8U",
    "cursor_expires_at": "2026-10-17T11:16:20.000Z",
    "has_more": true,
    "returned": 20
  },
  "warnings": [],
  "meta": {
    "capability": "wechat.posts.search",
    "result_status": "complete",
    "fetched_at": "2026-10-17T10:16:20.000Z",
    "cached": false,
    "replayed": false,
    "unavailable": {
      "lang": "capability",
      "author.id": "capability",
      "author.username": "capability",
      "author.verified": "capability",
      "author.followers": "capability",
      "metrics.comments": "capability",
      "metrics.shares": "capability",
      "metrics.views": "capability",
      "metrics.reposts": "capability",
      "images": "capability",
      "hashtags": "capability",
      "mentions": "capability",
      "is_pinned": "capability",
      "post_id": "platform",
      "parent_id": "platform",
      "root_id": "platform"
    },
    "billing": {
      "amount": "0.02",
      "currency": "USD",
      "balance_after": "9.98"
    }
  }
}
```

## 示例花多少钱

一个词的两页搜索结果

| 接口 | 调用次数 | 单价 | 小计 |
| --- | --- | --- | --- |
| [微信搜一搜综合搜索](https://dataxapi.com/zh/apis/wechat/posts/search/) | 2 | $0.0200 | $0.0400 |
| 合计 | 2 |  | $0.0400 |

价格是生成本页时的现行价格。失败的调用不收费。

## 在 AI 里做（MCP）

把 DataXAPI 接进你的 AI 客户端，只要接一次。之后直接说要什么，代理自己找到这些接口、看好价格，用你的余额调用。

这样说：用 DataXAPI 在微信搜一搜里搜“咖啡店开业”，取两页，列出每条的类型、来源账号、标题和日期。

代理发给 call 工具的参数：

```json
{
  "capability": "wechat.posts.search",
  "query": "咖啡店开业",
  "idempotency_key": "<a new UUID>"
}
```

[了解 MCP 服务](https://dataxapi.com/zh/mcp/)

## 要知道的

- 搜一搜不给账号编号，只给账号名称。要看这个号的其他文章，用文章详情接口打开其中一篇的链接，返回里的 `author.id` 就是它的原始编号。
- 搜不到结果时返回空结果，空结果也收费。

## 完整脚本

上面这件事写成一个能直接跑的脚本：Python，用 SDK，Key 从 DATAXAPI_API_KEY 读。它写出一个 CSV 文件，最后打印调了几次、取到几条、扣了多少。

```python
# pip install dataxapi
# export DATAXAPI_API_KEY=dx_...   (your key)
import csv
from decimal import Decimal
from dataxapi import DataXAPI

dx = DataXAPI()
calls, fetched, charged = 0, 0, Decimal("0")

def run(capability, params):
    """One call; counts it and what it was charged."""
    global calls, charged
    result = dx.call(capability, params)
    calls += 1
    charged += Decimal(str(result["meta"]["billing"]["amount"]))
    return result

QUERY = "咖啡店开业"
PAGES = 2

# WeChat Search results, articles and Channels videos mixed: type says which.
rows, cursor = [], None
for _ in range(PAGES):
    page = run("wechat.posts.search", {"query": QUERY, **({"cursor": cursor} if cursor else {})})
    for item in page["data"]["items"]:
        rows.append([item.get("type"), item.get("published_at"), item["author"].get("name"), item.get("title"), item.get("url")])
    cursor = page["page"]["next_cursor"]
    if not page["page"]["has_more"]:
        break

fetched = len(rows)
with open("wechat-search.csv", "w", newline="", encoding="utf-8") as file:
    csv.writer(file).writerows([["type", "published_at", "account", "title", "url"], *rows])

print(f"calls: {calls}, items: {fetched}, charged: ${charged}")
```

2026-10-29 真实跑过一次：调用 2 次，写出 40 行，扣费 $0.0400。失败的调用不收费。

## 用到的接口

- [微信搜一搜综合搜索](https://dataxapi.com/zh/apis/wechat/posts/search/)

## 微信搜一搜的更多内容

- [微信搜一搜 API](https://dataxapi.com/zh/apis/wechat/)
- [如何获取公众号历史文章列表](https://dataxapi.com/zh/guides/wechat-official-account-articles/)
- [如何获取公众号文章阅读数和点赞数](https://dataxapi.com/zh/guides/wechat-article-reads-and-likes/)
- [如何获取视频号视频评论](https://dataxapi.com/zh/guides/wechat-channels-video-comments/)
- [如何获取视频号账号的全部作品](https://dataxapi.com/zh/guides/wechat-channels-user-videos/)
- [公众号文章能用 API 读取吗？](https://dataxapi.com/zh/answers/is-there-an-api-for-wechat-official-account-articles/)
- [视频号数据怎么获取？](https://dataxapi.com/zh/answers/how-to-get-wechat-channels-data/)
- [公众号文章链接里的 __biz 是什么？](https://dataxapi.com/zh/answers/wechat-official-account-biz/)
- [公众号文章链接里的 mid、idx、sn 是什么意思？](https://dataxapi.com/zh/answers/wechat-article-link-mid-idx-sn/)
- [公众号原始 ID（gh_ 开头）是什么？](https://dataxapi.com/zh/answers/wechat-official-account-original-id/)
- [视频号的 …@finder 账号编号和 export 编号是什么？](https://dataxapi.com/zh/answers/wechat-channels-finder-id/)

---

目录修订号 5c3194deef3264cc。 [网页版](https://dataxapi.com/zh/guides/wechat-search-posts/)
