# X (Twitter) 直播状态 API (twitter.user_live)

- Canonical page: [https://everyinfra.com/twitter-api/user_live](https://everyinfra.com/twitter-api/user_live?utm_medium=ai_doc&utm_campaign=page_md)
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "twitter", "action": "user_live", "params": {...}}
- Price: $0.000556 per call ($0.56 per 1,000 requests); failed calls and empty results are not charged
- Returns: single object
- Mode: sync; add "mode": "async" for slow tasks

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| user_id | not declared | no | not declared | 账号的数字 ID，即 profile 返回的 user_id，或粉丝名单这类账号行里的 id；账号改名后数字 ID 不变。和 username 填一个就行。 |
| username | not declared | no | not declared | X 用户短名，可带 @，也可填主页链接；和 user_id 填一个就行，两个都填时以 username 为准。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| username | 用户名（@handle）。 |
| is_live | 账号此刻是否在直播（语音或视频 Space，或视频直播）。 |
| live_type | 直播的类型：space（Space）或 broadcast（视频直播）；没在直播时没有这个字段。 |
| live_id | Space 或直播的 ID；没在直播时没有这个字段。 |
| title | 标题。平台无标题概念时（如纯文本帖）为 null。 |
| started_at | 这场直播开始的时间；没在直播时没有这个字段。 |
| watching_count | 正在看的人数；只有视频直播有，Space 和没在直播时没有这个字段。 |
| 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": "user_live",
  "params": {
    "username": "NASA"
  }
}'
```

```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": "user_live",
        "params": {
            "username": "NASA",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

Real response to the example request above, captured 2026-11-21T07:22:03Z. `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": "user_live",
  "results": {
    "id": "11348282",
    "username": "NASA",
    "is_live": false,
    "platform": "twitter"
  },
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## 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
