# Facebook 评论 API (facebook.comments)

- Canonical page: https://everyinfra.com/facebook-api/comments
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "facebook", "action": "comments", "params": {...}}
- Price: $0.002778 per call ($2.78 per 1,000 requests); failed calls and empty results are not charged
- Returns: list, default 10, max 50 per call
- Mode: async by default (202 + job_id, poll GET /api/v1/jobs/{job_id})

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| url | not declared | yes | not declared | 按接口传目标：profile/user_posts 传公开主页，post/comments 传帖子，group_posts 传群组主页或群组标识，reviews 传商家主页（会补 /reviews）。不是任意 Facebook 链接均可用于所有接口。 |
| limit | integer (1–50) | no | 10 | 这次调用最多返回的条数，整数，1–50；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| author_name | 作者昵称（显示名）。 |
| author_username | 作者用户名（@handle），通常可用于拼 URL。 |
| depth | 评论层级：0 是顶层评论（一级），1 是对顶层评论的回复（二级），2 是对回复的再回复（三级）。深度行的 id 与其父评论组相同，重建评论树请用 depth + reply_to_id。主来源不可用时，备用来源只返回顶层评论：每一行的 depth 都是 0，没有回复行。 |
| reply_to_id | 被回复评论的 ID（depth>=1 才有；depth=0 恒为空）。回复行的 id 会复用父评论组 ID，要区分父子请以本字段为准。 |
| comment_url | 该条评论的永久链接；深度行的链接带 reply_comment_id 参数指向被回复的评论。 |
| author_id | 评论作者的数字用户 ID（稳定标识，可用于跨请求去重）。 |
| author_url | 评论作者的主页链接。 |
| like_count | 点赞数。null 表示该平台或该接口不公开此数据，不等于 0。 |
| reply_count | 回复数，通常用于评论的子回复。null 表示不公开。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| 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": "facebook",
  "action": "comments",
  "params": {
    "url": "https://www.facebook.com/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": "facebook",
        "action": "comments",
        "params": {
            "url": "https://www.facebook.com/nasa",
        },
    },
    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; the list keeps the first 2 of 16. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "facebook",
  "action": "comments",
  "results": [
    {
      "id": "•••",
      "text": "Houston, we have a Saturday. Four astronauts, one very big rocket, and zero 'just needs a little duct tape.' Go get 'em, Artemis crew. 🚀",
      "author_name": "•••",
      "author_username": "•••",
      "depth": 0,
      "comment_url": "https://www.facebook.com/reel/1803909017420449/?comment_id=1886311312779861",
      "author_id": "•••",
      "author_url": "https://www.facebook.com/•••",
      "like_count": 0,
      "posted_at": "2026-10-24T12:11:38+00:00",
      "platform": "facebook"
    },
    {
      "id": "•••",
      "text": "Excited to follow the next steps toward the lunar surface! 🚀 Which Artemis III test will be most critical to preparing for the landing?",
      "author_name": "•••",
      "author_username": "•••",
      "depth": 0,
      "comment_url": "https://www.facebook.com/reel/1803909017420449/?comment_id=2063125671029513",
      "author_id": "•••",
      "like_count": 0,
      "posted_at": "2026-10-24T08:06:31+00:00",
      "platform": "facebook"
    }
  ],
  "count": 16,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## Also

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