Facebook Ad Details
One Meta Ad Library ad by id or URL: advertiser, creative text, call to action, platforms, run dates and media.
- Price per call
- 2 credits
- per successful call
- Price ceiling
- 2 credits
- every call, same price
- Failed calls
- Free
- retried automatically
- Billed
- Per call
- only on success
Endpoint
api.primaryapi.com/ v1/ run/ facebook. ad_detailsAuth: 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/facebook.ad_details with the same body (free).
Example request
curl -sS -X POST "https://api.primaryapi.com/v1/run/facebook.ad_details" \
-H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"id":"1016451784037642"}'const res = await fetch('https://api.primaryapi.com/v1/run/facebook.ad_details', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PRIMARYAPI_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
id: '1016451784037642',
}),
});
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/facebook.ad_details",
headers={"Authorization": f"Bearer {os.environ['PRIMARYAPI_API_KEY']}"},
json={
"id": "1016451784037642",
},
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": "facebook.ad_details",
"input": {
"id": "1016451784037642"
}
}
}Price this exact input first (free)
curl -sS -X POST "https://api.primaryapi.com/v1/quote/facebook.ad_details" \
-H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"id":"1016451784037642"}'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.
idstring- Meta Ad Library archive id: the number after ?id= in an Ad Library URL (e.g. "962050096457659"). Provide id or url.pattern: ^\d{5,25}$
urlstring- Meta Ad Library ad URL (e.g. "https://www.facebook.com/ads/library?id=1185617869915074"). Provide id or url.max 2048 chars · pattern: ^https?:\/\/(?:[a-z0-9-]+\.)*facebook\.com\/ads\/library\/?\?(?:[^#]*&)?id=\d+
Output
When output.found is true, output.data has these fields.
idstring- Ad Library archive id (ad_archive_id)
adArchiveIdstring- Same value as id (AnyAPI field name)
activeboolean | null- Ad was delivering when scraped
pageIdstring | null- Advertiser page id
pageNamestring | nullpageUrlstring | nullpageProfilePicturestring | nullpageLikesinteger | nullpageCategoriesstring[]pageDeletedboolean | nulltextstring | null- Primary ad copy
bodystring | null- Same value as text (AnyAPI field name)
titlestring | null- Headline
captionstring | null- Display domain / link caption
linkDescriptionstring | nulllinkUrlstring | null- Landing page URL
ctaTextstring | nullctaTypestring | nulldisplayFormatstring | null- IMAGE, VIDEO, CAROUSEL, DCO, …
typeenum | null- video when the creative has a video, else image when it has oneone of: image, video
imagestring | null- First image (or video preview image) URL
videoUrlstring | null- First video URL
creativesobject[] | null- Per-card / per-version creative of multi-version ads ([] for single-creative ads, null when unknown)
creatives[].bodystring | nullcreatives[].titlestring | nullcreatives[].captionstring | nullcreatives[].linkDescriptionstring | nullcreatives[].linkUrlstring | nullcreatives[].ctaTextstring | nullcreatives[].ctaTypestring | nullcreatives[].imagestring | null- Full-size image URL (expiring CDN link)
creatives[].imageResizedstring | nullcreatives[].videoUrlstring | null- HD video URL when available, else SD
creatives[].videoPreviewImagestring | nullmediaobject[]media[].typeenum- one of: image, video
media[].urlstring | null- Image URL, or the preview image of a video
media[].videoUrlstring | nullstartDateinteger | null- Delivery start, Unix seconds
endDateinteger | null- Delivery end, Unix seconds; null while the ad is running
platformsstring[]- FACEBOOK, INSTAGRAM, MESSENGER, AUDIENCE_NETWORK, THREADS
isResharedboolean | nulladCountinteger | null- Ads sharing this creative (collation_count)
currencystring | null- Only disclosed for political / social-issue ads
categoriesstring[] | null- Special ad categories, when the source exposes them
sourceUrlstring- Ad Library permalink
urlstring- Same value as sourceUrl (AnyAPI field name)
TypeScript type
/** output.data when output.found is true */
type FacebookAdDetails = {
/** 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;
};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": {
"id": "1016451784037642",
"adArchiveId": "string",
"active": true,
"pageId": "string",
"pageName": "string",
"pageUrl": "https://example.com",
"pageProfilePicture": "string",
"pageLikes": 0,
"pageCategories": [
"string"
],
"pageDeleted": true,
"text": "string",
"body": "string",
"title": "string",
"caption": "string",
"linkDescription": "string",
"linkUrl": "https://example.com",
"ctaText": "string",
"ctaType": "string",
"displayFormat": "string",
"type": "image",
"image": "string",
"videoUrl": "https://example.com",
"creatives": [
{
"body": "string",
"title": "string",
"caption": "string",
"linkDescription": "string",
"linkUrl": "https://example.com",
"ctaText": "string",
"ctaType": "string",
"image": "string",
"imageResized": "string",
"videoUrl": "https://example.com",
"videoPreviewImage": "string"
}
],
"media": [
{
"type": "image",
"url": "https://example.com",
"videoUrl": "https://example.com"
}
],
"startDate": 0,
"endDate": 0,
"platforms": [
"string"
],
"isReshared": true,
"adCount": 0,
"currency": "string",
"categories": [
"string"
],
"sourceUrl": "https://example.com",
"url": "https://example.com"
}
},
"provider": "PrimaryAPI",
"credits": 2,
"items": 1,
"requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z"
}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
Ad media URLs are expiring CDN links; ad creative belongs to the advertiser: expose URLs only.
More Facebook endpoints
- Facebook Ad Creative Details2 credits
- Facebook Ad Library Advertiser Search2 credits
- Facebook Ad Library Search1 credit
- Facebook Company Ads2 credits
- Facebook Event Details2 credits
- Facebook Events by City2 credits
- Facebook Events Search2 credits
- Facebook Group Posts2 credits
- Facebook Marketplace Item2 credits
- Facebook Marketplace Search2 credits
- Facebook Page Contact Info2 credits
- Facebook Page Events2 credits
- Facebook Page Lookup by Name2 credits
- Facebook Page Photos2 credits
- Facebook Page Posts2 credits
- Facebook Page Profile2 credits
- Facebook Page Reels2 credits
- Facebook Page Search6.25 credits per result
- Facebook Post2 credits
- Facebook Post Comments2 credits
- Facebook Post Search3.24 credits per result
- Facebook Post Transcript2 credits
- Facebook Followers / Following ListPlanned
Generated from the PrimaryAPI catalog. Machine-readable contract: GET https://api.primaryapi.com/v1/apis/facebook.ad_details.