# Facebook 广告详情 API (facebook.ad_detail)

- Canonical page: https://everyinfra.com/facebook-api/ad_detail
- Endpoint: POST /api/v1/social with {"platform": "facebook", "action": "ad_detail", "params": {...}}
- Price: $0.000958 per call ($0.96 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=facebook&action=ad_detail

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| url | not declared | yes | not declared | 单条广告：广告库链接（https://www.facebook.com/ads/library/?id=<数字>）或纯数字广告 ID（ads 结果里的 id）。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在原平台上的可访问链接。 |
| is_active | 广告是否在投。 |
| started_at | 投放开始时间。 |
| ended_at | 投放结束时间。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| title | 标题。平台无标题概念时（如纯文本帖）为 null。 |
| caption | 广告里显示的落地页域名（ad_detail，如 example.com）。 |
| link_url | 广告落地页链接。分析竞品投放策略时最有用的字段。 |
| link_description | 广告链接卡片下方的描述文字（ad_detail）。 |
| cta_text | 行动按钮文案（如 Shop Now）。 |
| display_format | 广告形式（ad_detail）：IMAGE、VIDEO、CAROUSEL、DPA（动态商品广告）等。 |
| platforms | 投放平台（Facebook/Instagram/Messenger/AN）。 |
| media | 帖子的图片 / 视频：type、url（图片或视频封面）、width、height、link（点开的地址）。 |
| creatives | 广告的各个素材版本（ad_detail）：title、text、caption、link_url、link_description、cta_text、image_url、video_url。轮播和动态商品广告每张卡片一项。 |
| variant_count | 广告素材变体数。多变体说明在做 A/B 测试。 |
| advertiser_id | 广告主 ID。 |
| advertiser_name | 广告主名称。 |
| advertiser_url | 广告主主页。 |
| advertiser_likes | 广告主主页点赞数。 |
| advertiser_avatar_url | 广告主主页头像（ad_detail）。 |
| advertiser_categories | 广告主主页的类目（ad_detail）。 |
| 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": "ad_detail",
  "params": {
    "url": "https://www.facebook.com/ads/library/?id=900404412649714"
  }
}'
```

```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": "ad_detail",
        "params": {
            "url": "https://www.facebook.com/ads/library/?id=900404412649714",
        },
    },
    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": "facebook",
  "action": "ad_detail",
  "results": {
    "id": …,
    "url": …,
    "is_active": …,
    "started_at": …,
    "ended_at": …,
    "text": …,
    "title": …,
    "caption": …,
    "link_url": …,
    "link_description": …,
    "cta_text": …,
    "display_format": …,
    "platforms": …,
    "media": …,
    "creatives": …,
    "variant_count": …,
    "advertiser_id": …,
    "advertiser_name": …,
    "advertiser_url": …,
    "advertiser_likes": …,
    "advertiser_avatar_url": …,
    "advertiser_categories": …,
    "platform": …
  },
  "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
