# Facebook 广告素材 API (facebook.ads)

- Canonical page: https://everyinfra.com/facebook-api/ads
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "facebook", "action": "ads", "params": {...}}
- Price: $0.01179 per call ($11.79 per 1,000 requests); failed calls and empty results are not charged
- Returns: list, default 20, max 200 per call
- 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=ads

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | search 查公开帖子；ads 查广告关键词，也可传广告库/主页 URL；marketplace 查商品词，也可传完整 Marketplace 搜索 URL。三个入口范围不同，不是同一份结果换字段。 |
| country | not declared | no | not declared | ads 关键词查询的国家代码，例如 US，默认 US，构造 URL 时转为大写。keyword 已是完整 URL 时直接使用该 URL 中的条件，不再用此参数替换地区。 |
| status | not declared | no | not declared | 广告主页查询状态：all 全部（默认）、active 在投、inactive 已停投。这是投放状态，不是广告审核状态；keyword 传广告库 URL 时，URL 里自带的 active_status 可能与此参数不一致，建议两者保持一致。 |
| limit | integer (1–200) | no | 20 | 这次调用最多返回的条数，整数，1–200；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在原平台上的可访问链接。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| title | 标题。平台无标题概念时（如纯文本帖）为 null。 |
| cta_text | 行动按钮文案（如 Shop Now）。 |
| link_url | 广告落地页链接。分析竞品投放策略时最有用的字段。 |
| is_active | 广告是否在投。 |
| started_at | 投放开始时间。 |
| ended_at | 投放结束时间。 |
| platforms | 投放平台（Facebook/Instagram/Messenger/AN）。 |
| variant_count | 广告素材变体数。多变体说明在做 A/B 测试。 |
| advertiser_id | 广告主 ID。 |
| advertiser_name | 广告主名称。 |
| advertiser_url | 广告主主页。 |
| advertiser_likes | 广告主主页点赞数。 |
| image_url | 图片链接。多图能力可能返回 image_urls 数组。 |
| 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": "ads",
  "params": {
    "keyword": "coffee"
  }
}'
```

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

## Response example

Real response to the example request above, captured 2026-09-26T08:56:04Z. `results` and `count` are real with personal information (names, handles, avatars, profile links, contact details) removed; the list keeps the first 2 of 20. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "facebook",
  "action": "ads",
  "results": [
    {
      "id": "•••",
      "url": "https://www.facebook.com/ads/library/?id=2619351891814847",
      "text": "My aunt called me a creep for putting a camera in Nana’s living room.\n\nNana called me practical.\n\nThen the camera caught something worse than a fall.\n\nI need to be clear about one thing before anyone decides what kind of grandson I am.\n\nNana asked for the camera.\n\nNot me.\n\nNot my…",
      "title": "Natural Relief in Weeks",
      "cta_text": "Learn more",
      "link_url": "https://shop.pipitea.com/hbt/kd/sp-nm",
      "is_active": true,
      "started_at": "2026-07-18T07:00:00+00:00",
      "ended_at": "2026-09-26T07:00:00+00:00",
      "platforms": [
        "FACEBOOK",
        "INSTAGRAM",
        "AUDIENCE_NETWORK"
      ],
      "variant_count": 1,
      "advertiser_id": "•••",
      "advertiser_name": "American Health Support Community",
      "advertiser_url": "https://www.facebook.com/61588018263996/",
      "advertiser_likes": 3743,
      "image_url": "https://scontent-cgk2-1.xx.fbcdn.net/v/t39.35426-6/739782028_1533198008291919_1079542453788497101_n.jpg?stp=dst-jpg_s60x60_tt6&_nc_cat=104&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=Uk5VaZErAicQ7kNvwGVCoQR&_nc_oc=AdrmGRHEyarAKB4ZPK3UDbOqbmUnmyTjOu66kIImwuRMhy4Sih2v0Ql7lLBL18vE5Fc&_nc_zt=14&_…",
      "platform": "facebook"
    },
    {
      "id": "•••",
      "url": "https://www.facebook.com/ads/library/?id=1103440874425577",
      "text": "{{product.brand}}",
      "title": "{{product.name}}",
      "cta_text": "Learn more",
      "link_url": "https://fb.com/canvas_doc/1739639586863342",
      "is_active": false,
      "started_at": "2025-01-07T08:00:00+00:00",
      "ended_at": "2025-10-11T07:00:00+00:00",
      "platforms": [
        "FACEBOOK",
        "INSTAGRAM",
        "AUDIENCE_NETWORK"
      ],
      "variant_count": 1,
      "advertiser_id": "•••",
      "advertiser_name": "Kooks Secrets ",
      "advertiser_url": "https://www.facebook.com/Kookssecrets/",
      "advertiser_likes": 327993,
      "image_url": "https://scontent-cgk2-2.xx.fbcdn.net/v/t39.35426-6/472844243_1124200409414471_7229817135061190034_n.jpg?stp=dst-jpg_s60x60_tt6&_nc_cat=101&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=T5O8s9bDjU0Q7kNvwFxTL6x&_nc_oc=AdrpTq2DTLB8CkPZIM3_x98AEYJShX84dHiTij6LjERYIOCgDng9ayx9qOEMvr-YVRs&_nc_zt=14&_…",
      "platform": "facebook"
    }
  ],
  "count": 20,
  "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
