Meta Ad Library

Beta
Ads from the Meta ad library by keyword, page or URL: page, dates, platforms, creative, and spend and impressions where disclosed, as Apify-style dataset items.
POST/v1/ads/meta

Beta. 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.

Open as Markdown
On this page

Price

Pricead
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. A Bearer header with the key also works. Create a key.
Body
JSON objectMode: Live

Fields

  • startUrlsarray<object|string>optional
    Ad library URLs (a keyword search with q, country, ad_type and active_status, a page's ads with view_all_page_id, or one ad with id), or a Facebook page URL, which is searched by the page's name. Each entry is {"url": ...} or a plain string. urls is accepted too. Send this, searchTerms, or both.
    Example[{"url":"https://www.facebook.com/ads/library/?view_all_page_id=104512345678901"}]
    Show 1 child fields
    • urlstringrequired
      The URL.
      Examplehttps://www.facebook.com/ads/library/?q=trail%20shoes&country=US
  • urlsarray<object|string>optional
    Same as startUrls.
  • searchTermsarray<string>|stringoptional
    Keyword searches, one source each. searchTerm and search_terms are accepted too.
    Example["trail running shoes"]
  • searchTermstringoptional
    Same as searchTerms, for a single keyword.
  • search_termsarray<string>|stringoptional
    Same as searchTerms.
  • countrystringoptional
    Two-letter country the ads were shown in, or ALL. countryCode is accepted too. A country in an ad library URL wins for that URL.
    DefaultALLExampleUS
  • countryCodestringoptional
    Same as country.
  • adTypestringoptional
    ALL, or POLITICAL_AND_ISSUE_ADS for ads about social issues, elections or politics. ad_type is accepted too.
    DefaultALLOne ofALLPOLITICAL_AND_ISSUE_ADSExampleALL
  • activeStatusstringoptional
    Which ads: running now, stopped, or both. Unknown values fall back to all.
    DefaultallOne ofactiveinactiveallExampleactive
  • resultsLimitintegeroptional
    Most ads to return across all sources. count and maxItems are accepted too.
    Default100Min1Max5000Example50
  • countintegeroptional
    Same as resultsLimit.
  • maxItemsintegeroptional
    Same as resultsLimit.
  • limitPerSourceintegeroptional
    Most ads from any one URL or search term.
    Min1Max5000Example25
  • auto_upgradebooleanoptional
    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. false stops at the Standard level and returns the failure at $0. Also accepts "true", "false", 1 and 0.
    DefaulttrueExampletrue
  • max_levelstringoptional
    The highest fetch level Auto-upgrade may use. rendered never uses the Protected level.
    DefaultprotectedOne ofstandardrenderedprotectedExamplerendered
  • max_costnumberoptional
    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.
    Min0Example0.002
  • max_ageintegeroptional
    Accept a cached result up to this many seconds old, 0 to 86,400. 0 always 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|null
    The URL or search this ad came from.
    Examplehttps://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&media_type=all&q=trail+running+shoes&search_type=keyword_unordered
  • The ad's library id.
    Example1229350099285014
  • Same as adArchiveID, for clients that use this spelling.
    Example1229350099285014
  • adIdstring|null
    The ad id, when shown.
  • pageIDstring
    Id of the page that ran the ad.
    Example100200300400
  • pageIdstring
    Same as pageID.
    Example100200300400
  • pageNamestring|null
    Name of the page that ran the ad.
    ExampleSummit Running Co.
  • isActiveboolean
    True while the ad is running.
    Exampletrue
  • startDateinteger|null
    When the ad started, Unix seconds.
    Example1764547200
  • endDateinteger|null
    When the ad stopped, Unix seconds. Null while running.
  • startDate as ISO 8601.
    Example2025-12-01T00:00:00.000Z
  • endDateFormattedstring|null
    endDate as ISO 8601.
  • publisherPlatformarray<string>
    Where it ran, for example FACEBOOK, INSTAGRAM.
    Example["FACEBOOK","INSTAGRAM"]
  • collationCountinteger|null
    Number of near-identical ads grouped with this one.
    Example2
  • collationIdstring|null
    Id of that group.
    Example889900112233
  • categoriesarray<string>
    Ad categories, for example POLITICAL.
    Example["UNKNOWN"]
  • currencystring
    Currency of spend. Empty when not disclosed.
  • spendobject|string|null
    Amount spent, disclosed for political and issue ads.
  • Impressions, disclosed for political and issue ads.
    Show 3 child fields
    • impressionsTextstring|null
      Impression range as shown.
    • Impression bucket, -1 when not disclosed.
      Example-1
    • rangeobject|null
      Impression range {lower_bound, upper_bound}. Present for ads read from the library's data interface.
  • reachEstimateinteger|object|null
    Estimated reach, when disclosed.
  • Countries the ad targeted or reached.
    Example[]
  • snapshotobject
    The 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|null
    Link to the ad in the ad library.
    Examplehttps://www.facebook.com/ads/library/?id=1229350099285014
  • receipt_idstring|null
    Id of the ledger receipt for this request. Same on every item.
    Example8cbb5b5c-8e15-5c82-9959-45f93cdad009

Item types

Each entry in items has a type. These are the fields of each type.

ad24 fields
  • inputUrlstring|null
    The URL or search this ad came from.
  • The ad's library id.
  • Same as adArchiveID, for clients that use this spelling.
  • adIdstring|null
    The ad id, when shown.
  • pageIDstring
    Id of the page that ran the ad.
  • pageIdstring
    Same as pageID.
  • pageNamestring|null
    Name of the page that ran the ad.
  • isActiveboolean
    True while the ad is running.
  • startDateinteger|null
    When the ad started, Unix seconds.
  • endDateinteger|null
    When the ad stopped, Unix seconds. Null while running.
  • startDate as ISO 8601.
  • endDateFormattedstring|null
    endDate as ISO 8601.
  • publisherPlatformarray<string>
    Where it ran, for example FACEBOOK, INSTAGRAM.
  • collationCountinteger|null
    Number of near-identical ads grouped with this one.
  • collationIdstring|null
    Id of that group.
  • categoriesarray<string>
    Ad categories, for example POLITICAL.
  • currencystring
    Currency of spend. Empty when not disclosed.
  • spendobject|string|null
    Amount spent, disclosed for political and issue ads.
  • Impressions, disclosed for political and issue ads.
    Show 3 child fields
    • impressionsTextstring|null
      Impression range as shown.
    • Impression bucket, -1 when not disclosed.
    • rangeobject|null
      Impression range {lower_bound, upper_bound}. Present for ads read from the library's data interface.
  • reachEstimateinteger|object|null
    Estimated reach, when disclosed.
  • Countries the ad targeted or reached.
  • snapshotobject
    The 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|null
    Link to the ad in the ad library.
  • receipt_idstring|null
    Id of the ledger receipt for this request. Same on every item.

Errors

CodeWhen
400Invalid 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}}.
400Nothing found for the input (type: invalid-input). $0.
401No valid API key (type: user-or-token-not-found).
402Wallet balance below the worst case for this request (type: not-enough-usage-to-run-paid-actor).
429Too many requests (type: rate-limit-exceeded).
500No allowed fetch level got the page (type: internal-error). $0.
Tasks that end in an error are not billed. All status codes

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.