# TikTok 直播间 API (tiktok.live_room)

- Canonical page: https://everyinfra.com/tiktok-api/live_room
- Endpoint: POST /api/v1/social with {"platform": "tiktok", "action": "live_room", "params": {...}}
- Price: $0.000806 per call ($0.81 per 1,000 requests); failed 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=tiktok&action=live_room

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| username | not declared | yes | not declared | 要看直播间的 TikTok 账号：@短名（如 zachking，可带 @）或主页链接 https://www.tiktok.com/@<短名>；不收 sec_uid。没在直播时返回一行 is_live=false。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| username | 用户名（@handle）。 |
| display_name | 显示名，可能与 username 不同。 |
| user_id | 用户在原平台的唯一 ID。 |
| is_live | 账号此刻是否在直播（user_search）。 |
| room_id | 直播间 ID（live_room）；没在播的没有这个字段。 |
| url | 该记录在原平台上的可访问链接。 |
| title | 标题。平台无标题概念时（如纯文本帖）为 null。 |
| viewer_count | 调用那一刻的在线观众数（live_room）。 |
| peak_viewer_count | 本场直播的在线峰值（live_room）。 |
| total_viewer_count | 本场直播累计进入人次（live_room）。 |
| like_count | 点赞数。null 表示该平台或该接口不公开此数据，不等于 0。 |
| share_count | 分享/转发数。null 表示不公开，不等于 0。 |
| product_count | 带货商品数。 |
| started_at | platform-native meaning |
| cover_image_url | 视频封面图链接（带签名，会过期）。 |
| stream_url | 直播拉流地址（live_room，FLV，带签名、会过期）；没在播、在别人直播间连麦时没有。 |
| 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": "tiktok",
  "action": "live_room",
  "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": "tiktok",
        "action": "live_room",
        "params": {
            "username": "nasa",
        },
    },
    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": "tiktok",
  "action": "live_room",
  "results": {
    "username": …,
    "display_name": …,
    "user_id": …,
    "is_live": …,
    "room_id": …,
    "url": …,
    "title": …,
    "viewer_count": …,
    "peak_viewer_count": …,
    "total_viewer_count": …,
    "like_count": …,
    "share_count": …,
    "product_count": …,
    "started_at": …,
    "cover_image_url": …,
    "stream_url": …,
    "platform": …
  },
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## Also

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