# Ad Library Lookup (`ads.library_lookup`)

Advertiser name in, the first page of that advertiser's Meta Ad Library ads out (creative text, media, active flag, run dates, landing URL).

Docs: https://primaryapi.com/docs/api-reference/ads/library_lookup

- Endpoint: `POST https://api.primaryapi.com/v1/run/ads.library_lookup`
- Category: Web Intelligence · Platform: `ads` · Kind: composite · Status: live
- Price: 4 credits per call. Every call costs the same, including calls that were retried automatically.
- Billing unit: per successful call
- Reliability: routed to a healthy upstream and retried automatically when an attempt fails; live 30-day status: `GET https://api.primaryapi.com/v1/status/apis?sku=ads.library_lookup`
- Execution: synchronous (answers 202 only if it outlives the wait window)

## Input

| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
| `query` | string | yes |  | max 200 chars | Advertiser name as shown in the Meta Ad Library (e.g. "Nike"); the primary source matches it exactly and case-sensitively. |
| `platform` | enum | no | "facebook" | one of: facebook, meta | Ad library to query. Only the Meta (Facebook/Instagram) library is available; "meta" is an alias of "facebook". |
| `country` | string | no |  | pattern: ^(?:[A-Za-z]{2}\|ALL\|all)$ | Two-letter ISO country code the ads were delivered in (for example "US"), or ALL. Omit for all countries. |

Unknown fields are rejected with `400 invalid_input`. The routing controls `preferLatencyUnderMs` and `maxCredits` may be sent in the same JSON body.

## Output

When `output.found` is `true`, `output.data` has this shape:

| Field | Type | Description |
|---|---|---|
| `ads` | object[] |  |
| `ads[].id` | string | Ad Library archive id (ad_archive_id) |
| `ads[].adArchiveId` | string | Same value as id (AnyAPI field name) |
| `ads[].active` | boolean \| null | Ad was delivering when scraped |
| `ads[].pageId` | string \| null | Advertiser page id |
| `ads[].pageName` | string \| null |  |
| `ads[].pageUrl` | string \| null |  |
| `ads[].pageProfilePicture` | string \| null |  |
| `ads[].pageLikes` | integer \| null |  |
| `ads[].pageCategories` | string[] |  |
| `ads[].pageDeleted` | boolean \| null |  |
| `ads[].text` | string \| null | Primary ad copy |
| `ads[].body` | string \| null | Same value as text (AnyAPI field name) |
| `ads[].title` | string \| null | Headline |
| `ads[].caption` | string \| null | Display domain / link caption |
| `ads[].linkDescription` | string \| null |  |
| `ads[].linkUrl` | string \| null | Landing page URL |
| `ads[].ctaText` | string \| null |  |
| `ads[].ctaType` | string \| null |  |
| `ads[].displayFormat` | string \| null | IMAGE, VIDEO, CAROUSEL, DCO, … |
| `ads[].type` | enum \| null | video when the creative has a video, else image when it has one |
| `ads[].image` | string \| null | First image (or video preview image) URL |
| `ads[].videoUrl` | string \| null | First video URL |
| `ads[].creatives` | object[] \| null | Per-card / per-version creative of multi-version ads ([] for single-creative ads, null when unknown) |
| `ads[].creatives[].body` | string \| null |  |
| `ads[].creatives[].title` | string \| null |  |
| `ads[].creatives[].caption` | string \| null |  |
| `ads[].creatives[].linkDescription` | string \| null |  |
| `ads[].creatives[].linkUrl` | string \| null |  |
| `ads[].creatives[].ctaText` | string \| null |  |
| `ads[].creatives[].ctaType` | string \| null |  |
| `ads[].creatives[].image` | string \| null | Full-size image URL (expiring CDN link) |
| `ads[].creatives[].imageResized` | string \| null |  |
| `ads[].creatives[].videoUrl` | string \| null | HD video URL when available, else SD |
| `ads[].creatives[].videoPreviewImage` | string \| null |  |
| `ads[].media` | object[] |  |
| `ads[].media[].type` | enum |  |
| `ads[].media[].url` | string \| null | Image URL, or the preview image of a video |
| `ads[].media[].videoUrl` | string \| null |  |
| `ads[].startDate` | integer \| null | Delivery start, Unix seconds |
| `ads[].endDate` | integer \| null | Delivery end, Unix seconds; null while the ad is running |
| `ads[].platforms` | string[] | FACEBOOK, INSTAGRAM, MESSENGER, AUDIENCE_NETWORK, THREADS |
| `ads[].isReshared` | boolean \| null |  |
| `ads[].adCount` | integer \| null | Ads sharing this creative (collation_count) |
| `ads[].currency` | string \| null | Only disclosed for political / social-issue ads |
| `ads[].categories` | string[] \| null | Special ad categories, when the source exposes them |
| `ads[].sourceUrl` | string | Ad Library permalink |
| `ads[].url` | string | Same value as sourceUrl (AnyAPI field name) |
| `totalResults` | integer \| null | Total matches reported by the source (may be capped, e.g. 50001); null when unknown |
| `nextCursor` | string \| null |  |

When the thing you asked about does not exist (or a search matches nothing) the call still succeeds: `output.found` is `false`, `output.data` is `null` and `output.reason` says why (`not_found`, `private`, `no_results`, …). Misses are free unless the notes below say misses are billed.

## Example request

```bash
curl -sS -X POST "https://api.primaryapi.com/v1/run/ads.library_lookup" \
  -H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"Nike","platform":"facebook","country":"US"}'
```

## Example response

_Values are placeholders that follow the output schema; `credits` is what this call would cost at the usual price._

```json
{
  "output": {
    "found": true,
    "data": {
      "ads": [
        {
          "id": "1212560900568826",
          "adArchiveId": "1212560900568826",
          "active": true,
          "pageId": "15087023444",
          "pageName": "Nike",
          "pageUrl": "https://facebook.com/nike",
          "pageProfilePicture": "https://scontent-ord5-1.xx.fbcdn.net/v/t39.35426-6/508742493_1906025190144374_n.jpg",
          "pageLikes": 37497718,
          "pageCategories": [
            "Ropa deportiva"
          ],
          "pageDeleted": false,
          "text": "Que el frío no te detenga. Explora la colección de invierno con estilo y actitud Nike.",
          "body": "Que el frío no te detenga. Explora la colección de invierno con estilo y actitud Nike.",
          "title": "Look de invierno activado",
          "caption": "fb.com",
          "linkDescription": null,
          "linkUrl": "https://fb.com/canvas_doc/569658969305127",
          "ctaText": "Learn more",
          "ctaType": "LEARN_MORE",
          "displayFormat": "VIDEO",
          "media": [
            {
              "type": "video",
              "url": "https://scontent-ord5-3.xx.fbcdn.net/v/t39.35426-6/508472131_2706791729511119_n.jpg",
              "videoUrl": "https://video-ord5-2.xx.fbcdn.net/v/t42.1790-2/508345466_4710910465802253_n.mp4"
            }
          ],
          "image": "https://scontent-ord5-3.xx.fbcdn.net/v/t39.35426-6/508472131_2706791729511119_n.jpg",
          "videoUrl": "https://video-ord5-2.xx.fbcdn.net/v/t42.1790-2/508345466_4710910465802253_n.mp4",
          "type": "video",
          "creatives": [],
          "startDate": 1750143600,
          "endDate": null,
          "platforms": [
            "FACEBOOK"
          ],
          "isReshared": false,
          "adCount": null,
          "currency": null,
          "categories": null,
          "sourceUrl": "https://www.facebook.com/ads/library/?id=1212560900568826",
          "url": "https://www.facebook.com/ads/library/?id=1212560900568826"
        }
      ],
      "totalResults": null,
      "nextCursor": null
    }
  },
  "provider": "PrimaryAPI",
  "credits": 4,
  "items": 1,
  "requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z",
  "nextCursor": null
}
```

## Pricing and reliability

- Usual price: 4 credits per call
- Price ceiling: the usual price, even when a call is retried. A quote’s `maxCredits` is the most a given call can cost; the `maxCredits` routing control caps it per call
- Live 30-day status, success rate, uptime and latency: `GET https://api.primaryapi.com/v1/status/apis?sku=ads.library_lookup`

## Errors to handle

`invalid_input`, `unauthorized`, `insufficient_balance`, `key_limit_reached`, `trial_cap_reached`, `forbidden`, `not_found`, `idempotency_conflict`, `rate_limited`, `all_sources_failed`, `service_unavailable`, `timeout`. See https://primaryapi.com/docs/errors.

## Notes

Composite; charged once at this price and free when no ads are found (1Lookup bills only found results too). For deeper paging or filters call facebook.company_ads directly.

