# X (Twitter) 单条内容 API (twitter.post)

- Canonical page: https://everyinfra.com/twitter-api/post
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "twitter", "action": "post", "params": {...}}
- Price: $0.000556 per call ($0.56 per 1,000 requests); failed calls and empty results are not charged
- Returns: list
- Mode: sync; add "mode": "async" for slow tasks

单条推文按 `id` 读取一条帖子的完整记录：正文全文，点赞、转发、引用、书签和浏览数，作者的粉丝数与认证标识，以及 `media` 里的图片和视频。它回答「这一条帖子现在是什么状态」，适合核实一条被转发的内容、盯住一条重点帖的数据，或者把手里已有的帖子 ID 补全成可分析的记录。

`id` 填 x.com/用户名/status/ 后面的那串数字，不要把完整链接放进去。`tweet_id` 是 `id` 的兼容写法，两个都填时以 `id` 为准。`media` 的每一项带类型、地址和宽高，视频还有秒数和码率最高的 mp4 地址。`source` 记录发帖用的客户端，平台没给时没有这个键。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| id | not declared | yes | not declared | post / comments 的数字帖子 ID，即 x.com/用户名/status/ 后的数字，建议用字符串保存以避免 JavaScript 大整数精度损失；不要把完整 URL 放入 id。 |
| tweet_id | not declared | no | not declared | id 的兼容输入，优先级低于 id，不取消公开必填 id。 |
| limit | integer (1–) | no | not declared | 这次调用最多返回的条数，整数，至少为 1；不传按默认值，实际返回可能少于这个数。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在原平台上的可访问链接。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| like_count | 点赞数。null 表示该平台或该接口不公开此数据，不等于 0。 |
| retweet_count | 转发数。 |
| reply_count | 回复数，通常用于评论的子回复。null 表示不公开。 |
| view_count | 浏览/播放数。null 表示不公开，不等于 0。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| author_username | 作者用户名（@handle），通常可用于拼 URL。 |
| author_name | 作者昵称（显示名）。 |
| author_url | 作者在原平台的主页链接。 |
| author_follower_count | 作者粉丝数。null 表示不公开。 |
| quote_count | platform-native meaning |
| bookmark_count | 书签（收藏）数。 |
| language | 内容语言代码（如 zh、en），由平台判定，可能不准。 |
| conversation_id | 所属对话串 ID（根推文 ID），同一串的回复据此归在一起。 |
| is_reply | platform-native meaning |
| is_quote | 是否引用推文。 |
| is_repost | platform-native meaning |
| is_pinned | platform-native meaning |
| reply_to_id | platform-native meaning |
| reply_to_user_id | 所回复用户的数字 ID。 |
| reply_to | platform-native meaning |
| source | 发推客户端（如 Twitter for iPhone）；平台没给时没有这个键。 |
| media | 推文图片 / 视频：type（photo / video / animated_gif）、url（图片或视频封面）、width、height、duration_sec（视频秒数）、video_url（码率最高的 mp4）。 |
| hashtags | 正文里的话题标签数组，按出现顺序；没有时不出现这个字段。 |
| mentions | 正文里 @ 到的用户名。 |
| links | 正文里的外链（展开后的完整网址）。 |
| author_id | 作者在原平台的唯一 ID。 |
| author_avatar_url | 作者头像图片链接（多数平台带签名、会过期）。 |
| author_bio | platform-native meaning |
| author_is_verified | platform-native meaning |
| author_following_count | platform-native meaning |
| author_post_count | 作者推文总数。 |
| author_media_count | 作者发过的媒体数。 |
| author_created_at | platform-native meaning |
| author_banner_url | 作者主页横幅图链接。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |

## 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": "twitter",
  "action": "post",
  "params": {
    "id": "2103610284464316469"
  }
}'
```

```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": "twitter",
        "action": "post",
        "params": {
            "id": "2103610284464316469",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

Real response to the example request above, captured 2026-10-24T18:28:34Z. `results` and `count` are real with personal information (names, handles, avatars, profile links, contact details) removed. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "twitter",
  "action": "post",
  "results": [
    {
      "id": "2103610284464316469",
      "url": "https://x.com/NASA/status/2103610284464316469",
      "text": "With @•••, we’ll provide an update on Starliner development and plans for regular crew flights to and from the @••• Watch live Monday, Sept. 28 at 3pm ET: https://t.co/bxg2gpZzog https://t.co/OJaD49OyHh",
      "like_count": 4335,
      "retweet_count": 531,
      "reply_count": 235,
      "view_count": 998736,
      "posted_at": "2026-09-25T22:19:09+00:00",
      "author_username": "•••",
      "author_name": "•••",
      "author_url": "https://x.com/•••",
      "author_follower_count": 92311896,
      "quote_count": 66,
      "bookmark_count": 159,
      "language": "en",
      "conversation_id": "2103610284464316469",
      "is_reply": false,
      "is_quote": false,
      "is_repost": false,
      "is_pinned": false,
      "media": [
        {
          "type": "photo",
          "url": "https://pbs.twimg.com/media/HTGGPVlWUAAeapm.jpg",
          "width": 4096,
          "height": 2731
        }
      ],
      "mentions": [
        "BoeingSpace",
        "Space_Station"
      ],
      "links": [
        "https://go.nasa.gov/4AA9Ii5"
      ],
      "author_id": "•••",
      "author_avatar_url": "https://pbs.twimg.com/•••",
      "author_bio": "•••",
      "author_is_verified": true,
      "author_following_count": 115,
      "author_post_count": 74454,
      "author_media_count": 28207,
      "author_created_at": "2007-12-19T20:20:32+00:00",
      "author_banner_url": "https://pbs.twimg.com/profile_banners/11348282/1788992290",
      "platform": "twitter"
    }
  ],
  "count": 1,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### `id` 为什么建议当字符串保存？

帖子 ID 是很长的数字，直接转成 JavaScript 的数字类型会丢精度，存下来的值和原帖对不上，所以建议一直按字符串保存和传递。手里只有帖子链接时，取 /status/ 后面的数字填进来，不要整条 URL 一起填。

### 读一条帖子和读一个账号的帖子有什么区别？

这一页只读 `id` 指定的那一条。想看一个账号发过什么，改用用户内容那一页，传账号用户名，默认 20 条、单次最多 200 条；想看这条帖子之下的回复，用评论那一页，同样传帖子 ID。

### `view_count` 是 null 说明这条帖子没人看吗？

不是。null 表示这次拿不到浏览数，不等于 0，`like_count`、`reply_count` 的 null 也是同样的意思。读取一条帖子的数据变化时，把 null 记成缺失，别当成零；`posted_at` 是 UTC 时间，换时区后再和别处的数据对齐。

## Also

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