Ad 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).
- Price per call
- 4 credits
- per successful call
- Price ceiling
- 4 credits
- every call, same price
- Failed calls
- Free
- retried automatically
- Billed
- Per call
- only on success
Endpoint
api.primaryapi.com/ v1/ run/ ads. library_lookupAuth: API key with run or full access, or a dashboard session
Send the input below as a JSON body. The call is routed to a healthy upstream; if an attempt fails, it is retried automatically inside the same request and you pay only for the answer you get. To check an input and see the exact price without running anything, call POST /v1/quote/ads.library_lookup with the same body (free).
Example request
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"}'const res = await fetch('https://api.primaryapi.com/v1/run/ads.library_lookup', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PRIMARYAPI_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: 'Nike',
platform: 'facebook',
country: 'US',
}),
});
const body = await res.json();
if (!res.ok) throw new Error(`${body.code}: ${body.error}`);
// found:false is a successful answer ("does not exist"), not an error
console.log(body.output.found ? body.output.data : body.output.reason, body.credits);import os
import requests
res = requests.post(
"https://api.primaryapi.com/v1/run/ads.library_lookup",
headers={"Authorization": f"Bearer {os.environ['PRIMARYAPI_API_KEY']}"},
json={
"query": "Nike",
"platform": "facebook",
"country": "US",
},
timeout=60,
)
body = res.json()
if not res.ok:
raise RuntimeError(f"{body['code']}: {body['error']}")
# found=False is a successful answer ("does not exist"), not an error
print(body["output"]["data"] if body["output"]["found"] else body["output"]["reason"], body["credits"]){
"name": "run_api",
"arguments": {
"sku": "ads.library_lookup",
"input": {
"query": "Nike",
"platform": "facebook",
"country": "US"
}
}
}Price this exact input first (free)
curl -sS -X POST "https://api.primaryapi.com/v1/quote/ads.library_lookup" \
-H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query":"Nike","platform":"facebook","country":"US"}'Returns credits (what the call is expected to cost) and maxCredits (the most it can cost, which is set aside while it runs). Invalid input fails here the same way it would on run.
Input
JSON body fields. Unknown fields are rejected with 400 invalid_input (never silently ignored). You may add the routing controls preferLatencyUnderMs and maxCredits to the same object.
querystringrequired- Advertiser name as shown in the Meta Ad Library (e.g. "Nike"); the primary source matches it exactly and case-sensitively.max 200 chars
platformenumdefault"facebook"- Ad library to query. Only the Meta (Facebook/Instagram) library is available; "meta" is an alias of "facebook".one of: facebook, meta
countrystring- Two-letter ISO country code the ads were delivered in (for example "US"), or ALL. Omit for all countries.pattern: ^(?:[A-Za-z]{2}|ALL|all)$
Output
When output.found is true, output.data has these fields (a list under ads, billed per item returned).
adsobject[]ads[].idstring- Ad Library archive id (ad_archive_id)
ads[].adArchiveIdstring- Same value as id (AnyAPI field name)
ads[].activeboolean | null- Ad was delivering when scraped
ads[].pageIdstring | null- Advertiser page id
ads[].pageNamestring | nullads[].pageUrlstring | nullads[].pageProfilePicturestring | nullads[].pageLikesinteger | nullads[].pageCategoriesstring[]ads[].pageDeletedboolean | nullads[].textstring | null- Primary ad copy
ads[].bodystring | null- Same value as text (AnyAPI field name)
ads[].titlestring | null- Headline
ads[].captionstring | null- Display domain / link caption
ads[].linkDescriptionstring | nullads[].linkUrlstring | null- Landing page URL
ads[].ctaTextstring | nullads[].ctaTypestring | nullads[].displayFormatstring | null- IMAGE, VIDEO, CAROUSEL, DCO, …
ads[].typeenum | null- video when the creative has a video, else image when it has oneone of: image, video
ads[].imagestring | null- First image (or video preview image) URL
ads[].videoUrlstring | null- First video URL
ads[].creativesobject[] | null- Per-card / per-version creative of multi-version ads ([] for single-creative ads, null when unknown)
ads[].creatives[].bodystring | nullads[].creatives[].titlestring | nullads[].creatives[].captionstring | nullads[].creatives[].linkDescriptionstring | nullads[].creatives[].linkUrlstring | nullads[].creatives[].ctaTextstring | nullads[].creatives[].ctaTypestring | nullads[].creatives[].imagestring | null- Full-size image URL (expiring CDN link)
ads[].creatives[].imageResizedstring | nullads[].creatives[].videoUrlstring | null- HD video URL when available, else SD
ads[].creatives[].videoPreviewImagestring | nullads[].mediaobject[]ads[].media[].typeenum- one of: image, video
ads[].media[].urlstring | null- Image URL, or the preview image of a video
ads[].media[].videoUrlstring | nullads[].startDateinteger | null- Delivery start, Unix seconds
ads[].endDateinteger | null- Delivery end, Unix seconds; null while the ad is running
ads[].platformsstring[]- FACEBOOK, INSTAGRAM, MESSENGER, AUDIENCE_NETWORK, THREADS
ads[].isResharedboolean | nullads[].adCountinteger | null- Ads sharing this creative (collation_count)
ads[].currencystring | null- Only disclosed for political / social-issue ads
ads[].categoriesstring[] | null- Special ad categories, when the source exposes them
ads[].sourceUrlstring- Ad Library permalink
ads[].urlstring- Same value as sourceUrl (AnyAPI field name)
totalResultsinteger | null- Total matches reported by the source (may be capped, e.g. 50001); null when unknown
nextCursorstring | null
TypeScript type
/** output.data when output.found is true */
type AdsLibraryLookup = {
ads: {
/** Ad Library archive id (ad_archive_id) */
id: string;
/** Same value as id (AnyAPI field name) */
adArchiveId: string;
/** Ad was delivering when scraped */
active: boolean | null;
/** Advertiser page id */
pageId: string | null;
pageName: string | null;
pageUrl: string | null;
pageProfilePicture: string | null;
pageLikes: number | null;
pageCategories: string[];
pageDeleted: boolean | null;
/** Primary ad copy */
text: string | null;
/** Same value as text (AnyAPI field name) */
body: string | null;
/** Headline */
title: string | null;
/** Display domain / link caption */
caption: string | null;
linkDescription: string | null;
/** Landing page URL */
linkUrl: string | null;
ctaText: string | null;
ctaType: string | null;
/** IMAGE, VIDEO, CAROUSEL, DCO, … */
displayFormat: string | null;
/** video when the creative has a video, else image when it has one */
type: "image" | "video" | null;
/** First image (or video preview image) URL */
image: string | null;
/** First video URL */
videoUrl: string | null;
/** Per-card / per-version creative of multi-version ads ([] for single-creative ads, null when unknown) */
creatives: {
body: string | null;
title: string | null;
caption: string | null;
linkDescription: string | null;
linkUrl: string | null;
ctaText: string | null;
ctaType: string | null;
/** Full-size image URL (expiring CDN link) */
image: string | null;
imageResized: string | null;
/** HD video URL when available, else SD */
videoUrl: string | null;
videoPreviewImage: string | null;
}[] | null;
media: {
type: "image" | "video";
/** Image URL, or the preview image of a video */
url: string | null;
videoUrl: string | null;
}[];
/** Delivery start, Unix seconds */
startDate: number | null;
/** Delivery end, Unix seconds; null while the ad is running */
endDate: number | null;
/** FACEBOOK, INSTAGRAM, MESSENGER, AUDIENCE_NETWORK, THREADS */
platforms: string[];
isReshared: boolean | null;
/** Ads sharing this creative (collation_count) */
adCount: number | null;
/** Only disclosed for political / social-issue ads */
currency: string | null;
/** Special ad categories, when the source exposes them */
categories: string[] | null;
/** Ad Library permalink */
sourceUrl: string;
/** Same value as sourceUrl (AnyAPI field name) */
url: string;
}[];
/** Total matches reported by the source (may be capped, e.g. 50001); null when unknown */
totalResults: number | null;
nextCursor: string | null;
};If what you asked about does not exist, is private, or a search matches nothing, the call still succeeds: output.found is false, output.data is null and output.reason says why. Such misses are free unless the notes below say misses are billed, in which case a miss costs the price of one call.
Example response
Values are placeholders that follow the output schema (strings as "string", numbers as 0); credits shows what this call would cost at the usual price.
{
"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
Calls go only to upstreams that are healthy right now. If an attempt fails, the call is retried automatically inside the same request; a failed attempt costs nothing, and a call never costs more than its quote’s maxCredits. Live figures below are measured on real traffic.
Success rate, uptime, latency and call counts are measured live from real traffic over 30 days and show “—” until there is data.
Errors
Errors are JSON { code, error, requestId } and are never charged. The ones to handle for this endpoint:
- invalid_inputThe request failed validation before anything ran.
- unauthorizedNo valid API key or session was presented.
- insufficient_balanceThe balance cannot cover the most this call could cost.
- key_limit_reachedThe key’s own spend limit is used up for the current window.
- trial_cap_reachedAn agent trial key has used its whole trial budget.
- forbiddenThe credential is valid but may not do this.
- not_foundThe thing addressed by the URL does not exist for you.
- idempotency_conflictThe
Idempotency-Keyis already bound to a different request. - rate_limitedToo many requests in the current window.
- all_sources_failedThe call could not be answered, even after automatic retries.
- service_unavailableThis API cannot run in this deployment right now.
- timeoutThe request passed its deadline before it finished.
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.
Generated from the PrimaryAPI catalog. Machine-readable contract: GET https://api.primaryapi.com/v1/apis/ads.library_lookup.