X search_posts API
一次 REST 调用获取 X search_posts 数据——按 FetchPI 全平台共享的稳定 JSON 模式标准化输出。
- 1 个已发布端点
- GET /v1/x/search/posts
契约摘要(英文): Search X posts (capability x.search_posts)
- 标准化响应实体
- x/search_posts
- capability
- x.search_posts
每个响应还携带新鲜度(cache / default / live)与计费元数据。
使用场景
- 按关键词检索 {{platform}} 内容与账号,返回标准化结果,直接可用于打分排序。
- 追踪热门话题与热榜,第一时间捕捉新兴讨论。
- 对搜索与趋势查询建立告警,让团队实时感知变化。
返回字段
X post search response (normalized envelope)
Response envelope for GET /v1/x/search/posts (capability x.search_posts). Same normalized post entities as user_posts; echoes the effective query.
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| query | string | 可选 | Echo of the effective search query. |
| data | post[] | 必填 | — |
| next_cursor | string | null | 必填 | Opaque pagination cursor; null when results are exhausted. Cursor validity is tied to the provider that produced the page. |
| meta.request_id | string | 必填 | — |
| meta.freshness.mode | cache | default | live | 必填 | — |
| meta.freshness.age_seconds | integer | null | 可选 | — |
| meta.freshness.source_layer | cache | db | upstream | 必填 | — |
| meta.freshness.stale | boolean | 可选 | — |
| meta.billing.cache_hit | boolean | 必填 | — |
| meta.billing.amount_credits | integer | 必填 | Credits actually charged for this request (the settlement unit; 1 credit = $0.0001, permanent). |
字段备注为契约英文原文。
响应元数据
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| mode | cache | default | live | 必填 | Effective mode after merging param > max_age > source policy (D-004). |
| age_seconds | integer | null | 可选 | Age of served data; null when unknown. |
| source_layer | cache | db | upstream | 必填 | Which layer served the response (PRD §10). |
| stale | boolean | 可选 | True when stale data was served under stale_if_error / SWR (D-004). |
| billing.amount_credits | integer | 必填 | Micro-USD (1e-6 USD) actually charged for this request. |
| billing.cache_hit | boolean | 必填 | — |
字段备注为契约英文原文。
请求与响应示例
GET
/v1/x/search/postscurl -H "Authorization: Bearer $MESHDATA_API_KEY" \
"https://api.fetchpi.com/v1/x/search/posts?q=meshdata"{
"data": [
{
"id": "1841001111111111111",
"platform": "x",
"type": "post",
"author": {
"id": "5566778899",
"username": "datafan",
"display_name": "Data Fan",
"verified": true
},
"text": "meshdata launch day!",
"lang": "en",
"created_at": "2026-09-15T10:00:00Z",
"metrics": {
"likes": 9,
"reposts": 2,
"replies": 0,
"quotes": 0,
"views": 340
},
"in_reply_to": null,
"attachments": [],
"fetched_at": "2026-09-18T09:05:00Z"
}
],
"next_cursor": null,
"meta": {
"request_id": "req_01HTXQ8Z9HTQ",
"freshness": {
"mode": "live",
"age_seconds": 0,
"source_layer": "upstream",
"stale": false
},
"billing": {
"amount_credits": 300,
"cache_hit": false
}
}
}免费试用
注册免费账号、获取 API Key,即可在浏览器版 Playground 中直接调用该端点。
在 Playground 中试用该端点的参数表、错误码与响应语义见 API 文档。
查看端点参考常见问题
cache 与 live 新鲜度有什么区别?
cache 直接返回已存快照、不触碰上游;live 查询更新的数据,可能产生额外积分费用——详见文档的新鲜度说明。
可以免费试用该端点吗?
可以——注册账号、拿到 API Key 后,即可在控制台的 Playground 中调用该端点。
search_posts 能力怎么计费?
Data API 按请求以积分计费,cache/live 新鲜度有不同倍率。当前各能力的价格以价格页为准。