Meta Ad Library
Beta/v1/ads/metaBeta. The parser for this endpoint was written from the upstream format and has not yet been checked against a live response. Field shapes may change; tell us if you see a mismatch.
On this page
Price
- Live
- $0.00018
Per ad returned.
Description
POST the input as one JSON object. Each URL and each search term is a source; ads are collected source by source until resultsLimit is reached. Only the first page of library results is read for each source.
The response body is a JSON array of items, with no wrapper. Every item carries receipt_id, and the same id is in the X-Receipt-Id response header.
Billing. Per ad returned, whatever fetch level was needed. An input that finds no ads costs $0. Results are cached for 6 h.
Beta. The parser behind this route was written from public documentation and hasn't been checked against live pages yet. Item field names are fixed; some values may be null more often than they should be until that check is done.
Request
- Endpoint
- POST https://api.dataforgaio.com/v1/ads/meta
- Authentication
- HTTP Basic auth: any login, with your
dg_API key as the password. ABearerheader with the key also works. Create a key. - Body
- JSON objectMode: Live
Fields
- Ad library URLs (a keyword search with
q,country,ad_typeandactive_status, a page's ads withview_all_page_id, or one ad withid), or a Facebook page URL, which is searched by the page's name. Each entry is{"url": ...}or a plain string.urlsis accepted too. Send this,searchTerms, or both.Example[{"url":"https://www.facebook.com/ads/library/?view_all_page_id=104512345678901"}]Show 1 child fieldsHide child fields
- The URL.Example
https://www.facebook.com/ads/library/?q=trail%20shoes&country=US
- The URL.
- Same as
startUrls. - Keyword searches, one source each.
searchTermandsearch_termsare accepted too.Example["trail running shoes"] - Same as
searchTerms, for a single keyword. - Same as
searchTerms. - Two-letter country the ads were shown in, or
ALL.countryCodeis accepted too. A country in an ad library URL wins for that URL.DefaultALLExampleUS - Same as
country. ALL, orPOLITICAL_AND_ISSUE_ADSfor ads about social issues, elections or politics.ad_typeis accepted too.DefaultALLOne ofALLPOLITICAL_AND_ISSUE_ADSExampleALL- Which ads: running now, stopped, or both. Unknown values fall back to
all.DefaultallOne ofactiveinactiveallExampleactive - Most ads to return across all sources.
countandmaxItemsare accepted too.Default100Min1Max5000Example50 - Same as
resultsLimit. - Same as
resultsLimit. - Most ads from any one URL or search term.Min
1Max5000Example25 - Lets the request move to a higher fetch level when the included level can't get the data, billed at the level that delivered it.
falsestops at the Standard level and returns the failure at $0. Also accepts"true","false",1and0.DefaulttrueExampletrue - The highest fetch level Auto-upgrade may use.
renderednever uses the Protected level.DefaultprotectedOne ofstandardrenderedprotectedExamplerendered - The most this task may cost, in USD. The wallet check reserves this amount instead of the worst-case price, the request never upgrades past it, and the charge never exceeds it. Ads stop at the number this amount pays for.Min
0Example0.002 - Accept a cached result up to this many seconds old, 0 to 86,400.
0always fetches fresh. Default window: 6 h.Min0Max86400Example3600
Response
Shape: Apify actor shape. Expand a field to see its children; every field has a link anchor.
- inputUrlstring|nullThe URL or search this ad came from.Example
https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&media_type=all&q=trail+running+shoes&search_type=keyword_unordered - adArchiveIDstringThe ad's library id.Example
1229350099285014 - adArchiveIdstringSame as
adArchiveID, for clients that use this spelling.Example1229350099285014 - adIdstring|nullThe ad id, when shown.
- pageIDstringId of the page that ran the ad.Example
100200300400 - pageIdstringSame as
pageID.Example100200300400 - pageNamestring|nullName of the page that ran the ad.Example
Summit Running Co. - isActivebooleanTrue while the ad is running.Example
true - startDateinteger|nullWhen the ad started, Unix seconds.Example
1764547200 - endDateinteger|nullWhen the ad stopped, Unix seconds. Null while running.
- startDateFormattedstring|null
startDateas ISO 8601.Example2025-12-01T00:00:00.000Z - endDateFormattedstring|null
endDateas ISO 8601. - publisherPlatformarray<string>Where it ran, for example
FACEBOOK,INSTAGRAM.Example["FACEBOOK","INSTAGRAM"] - collationCountinteger|nullNumber of near-identical ads grouped with this one.Example
2 - collationIdstring|nullId of that group.Example
889900112233 - categoriesarray<string>Ad categories, for example
POLITICAL.Example["UNKNOWN"] - currencystringCurrency of
spend. Empty when not disclosed. - spendobject|string|nullAmount spent, disclosed for political and issue ads.
- impressionsWithIndexobjectImpressions, disclosed for political and issue ads.
Show 3 child fieldsHide child fields
- impressionsTextstring|nullImpression range as shown.
- impressionsIndexintegerImpression bucket,
-1when not disclosed.Example-1 - rangeobject|nullImpression range
{lower_bound, upper_bound}. Present for ads read from the library's data interface.
- reachEstimateinteger|object|nullEstimated reach, when disclosed.
- targetedOrReachedCountriesarray<string>Countries the ad targeted or reached.Example
[] - snapshotobjectThe ad's creative: page name, body text, title, link, call to action, images, videos and cards. Keys are camelCase; which keys are present depends on where the ad was read.Example
{"pageName":"Summit Running Co.","body":{"text":"New trail shoes for winter. Free gait analysis."},"title":"Shop trail shoes","linkUrl":"https://summitrunning.example/trail-shoes","ctaText":"Shop now","ctaType":"SHOP_NOW"} - urlstring|nullLink to the ad in the ad library.Example
https://www.facebook.com/ads/library/?id=1229350099285014 - receipt_idstring|nullId of the ledger receipt for this request. Same on every item.Example
8cbb5b5c-8e15-5c82-9959-45f93cdad009
Item types
Each entry in items has a type. These are the fields of each type.
ad24 fields
- inputUrlstring|nullThe URL or search this ad came from.
- adArchiveIDstringThe ad's library id.
- adArchiveIdstringSame as
adArchiveID, for clients that use this spelling. - adIdstring|nullThe ad id, when shown.
- pageIDstringId of the page that ran the ad.
- pageIdstringSame as
pageID. - pageNamestring|nullName of the page that ran the ad.
- isActivebooleanTrue while the ad is running.
- startDateinteger|nullWhen the ad started, Unix seconds.
- endDateinteger|nullWhen the ad stopped, Unix seconds. Null while running.
- startDateFormattedstring|null
startDateas ISO 8601. - endDateFormattedstring|null
endDateas ISO 8601. - publisherPlatformarray<string>Where it ran, for example
FACEBOOK,INSTAGRAM. - collationCountinteger|nullNumber of near-identical ads grouped with this one.
- collationIdstring|nullId of that group.
- categoriesarray<string>Ad categories, for example
POLITICAL. - currencystringCurrency of
spend. Empty when not disclosed. - spendobject|string|nullAmount spent, disclosed for political and issue ads.
- impressionsWithIndexobjectImpressions, disclosed for political and issue ads.
Show 3 child fieldsHide child fields
- impressionsTextstring|nullImpression range as shown.
- impressionsIndexintegerImpression bucket,
-1when not disclosed. - rangeobject|nullImpression range
{lower_bound, upper_bound}. Present for ads read from the library's data interface.
- reachEstimateinteger|object|nullEstimated reach, when disclosed.
- targetedOrReachedCountriesarray<string>Countries the ad targeted or reached.
- snapshotobjectThe ad's creative: page name, body text, title, link, call to action, images, videos and cards. Keys are camelCase; which keys are present depends on where the ad was read.
- urlstring|nullLink to the ad in the ad library.
- receipt_idstring|nullId of the ledger receipt for this request. Same on every item.
Errors
| Code | When |
|---|---|
| 400 | Invalid input (no URL or search term, a non-Facebook URL, or an unknown adType), or max_cost below the price of one item. Body: {"error": {"type": "invalid-input", "message": ..., "receipt_id": null}}. |
| 400 | Nothing found for the input (type: invalid-input). $0. |
| 401 | No valid API key (type: user-or-token-not-found). |
| 402 | Wallet balance below the worst case for this request (type: not-enough-usage-to-run-paid-actor). |
| 429 | Too many requests (type: rate-limit-exceeded). |
| 500 | No allowed fetch level got the page (type: internal-error). $0. |
Migrating
Replaces Apify Facebook Ads Library actor input and dataset items. The request body and response envelope match: change the base URL to https://api.dataforgaio.com/v1 and use your dg_ key as the password.