# Facebook Ads API (facebook.ads)

- Canonical page: https://everyinfra.com/en/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 | Specifies the search query for distinct platform endpoints. For search, it searches public posts; for ads, it accepts ad keywords or direct Ad Library and Page URLs; for marketplace, it accepts item search terms or complete Marketplace search URLs. Each action queries a different dataset rather than returning the same results under different field names. |
| country | not declared | no | not declared | Specifies the country code for keyword queries in the ads action, such as US (defaults to US). Values are converted to uppercase when constructing request URLs. If keyword is provided as a complete URL, the parameters embedded in that URL take precedence and this country setting is not applied. |
| status | not declared | no | not declared | Filters ad page status with allowed values: all (default), active (currently running), or inactive (stopped). This represents ad delivery status rather than ad review status. When keyword is an Ad Library URL, its embedded active_status may differ from this parameter; keep the two consistent. |
| limit | integer (1–200) | no | 20 | The most rows to return in this call, an integer from 1 to 200. The default applies when you leave it out, and a call can return fewer rows. Larger values return 422 before any charge. |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | The record's unique ID on the platform. Unique only within one platform; IDs can repeat across platforms. |
| url | Link to the record on the platform. |
| text | Body text with HTML removed, returned in full and never cut short (on a few platforms the list results themselves carry only an excerpt; the platform's field notes say so). |
| title | Title. null when the platform has no titles (for example text-only posts). |
| cta_text | platform-native meaning |
| link_url | platform-native meaning |
| is_active | platform-native meaning |
| started_at | platform-native meaning |
| ended_at | platform-native meaning |
| platforms | platform-native meaning |
| variant_count | platform-native meaning |
| advertiser_id | platform-native meaning |
| advertiser_name | platform-native meaning |
| advertiser_url | platform-native meaning |
| advertiser_likes | platform-native meaning |
| image_url | Image link. Capabilities with several images may return an image_urls array. |
| platform | Source platform identifier, the same as platform in the request (for example 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
