Facebook Ads Library Scraper avatar

Facebook Ads Library Scraper

Pricing

from $0.73 / 1,000 ads

Go to Apify Store
Facebook Ads Library Scraper

Facebook Ads Library Scraper

Scrape ads from Meta's public Facebook Ads Library by keyword or Page ID.

Pricing

from $0.73 / 1,000 ads

Rating

0.0

(0)

Developer

Chengliang Lin

Chengliang Lin

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

20 hours ago

Last modified

Share

Scrape ads from Meta's public Ads Library by keyword or advertiser Page ID.

The Actor opens the Ads Library in a browser, intercepts GraphQL responses, and writes one Dataset row per ad plus a single ads-by-page.json file in the default Key-Value Store.

This is not the official Graph API ads_archive endpoint. That API only returns political / issue ads in most regions. This Actor uses the public library page, so it can collect commercial ads.

README.zh-Hant.md · README.ja.md

Input

Provide either query or pageId. If both are set, pageId wins and query is ignored.

ParameterTypeRequiredDefaultDescription
queryStringYes, unless pageId is setKeyword to search in the Ads Library.
pageIdStringYes, unless query is setNumeric Facebook Page ID. Lists that advertiser's ads.
countryStringNoTWISO country code, or ALL. Allowed: ALL, TW, US, GB, JP, KR, SG, HK, AU, CA, DE, FR.
categoryStringNoallAd category. all, political_and_issue_ads, housing_ads, employment_ads, credit_ads.
mediaTypeStringNoallCreative type. all, image, meme, image_and_meme, video, none.
sortByStringNomostRecentResult order. mostRecent or impressions.
activeStatusStringNoactiveactive, inactive, or all. Use all when searching historical ads.
minDateStringNoOnly ads that started running on or after this date (YYYY-MM-DD).
maxDateStringNoOnly ads that started running on or before this date (YYYY-MM-DD).
maxItemsIntegerNo20Maximum number of ads to collect (1500).
maxScrollRoundsIntegerNoscales with maxItemsHow many times to scroll for more results (180). Leave empty to scale automatically.
proxyProxyNoResidentialApify Proxy. Use Residential; datacenter IPs typically get HTTP 403 from Meta.

Example input

{
"query": "skincare",
"country": "TW",
"category": "all",
"mediaType": "all",
"sortBy": "mostRecent",
"activeStatus": "active",
"minDate": "2026-01-01",
"maxDate": "2026-06-30",
"maxItems": 20
}

minDate / maxDate match the Ads Library date picker (start-running date), not “was delivering during this window”.

Output

Each ad is written to the default Dataset (one row per ad, shown as a table in Console). The same ads are grouped by advertiser in one Key-Value Store file.

StorageKey / itemDescription
Datasetone item per adTable view in Console. Use this for CSV / Excel export.
Key-Value Storeads-by-page.jsonObject keyed by page_id (or unknown-{ad_archive_id}), each value an array of ads.
Key-Value StoreOUTPUTRun summary: adCount, pageCount, files.

OUTPUT record

FieldTypeDescription
adCountIntegerNumber of ads saved.
pageCountIntegerNumber of advertiser keys in ads-by-page.json.
filesString[]List of Key-Value Store keys that were written.

Ad object

Each ad in the Dataset and in ads-by-page.json has these fields:

FieldTypeDescription
ad_archive_idStringAds Library archive ID.
page_idString | nullAdvertiser Facebook Page ID.
page_nameString | nullAdvertiser page name.
is_activeBoolean | nullWhether the ad is currently running.
start_dateNumber | nullUnix timestamp (seconds) when the ad started running.
end_dateNumber | nullUnix timestamp (seconds) when the ad stopped, if ended.
publisher_platformString[]Platforms such as FACEBOOK, INSTAGRAM.
body_textStringPrimary ad copy.
titleString | nullHeadline / title.
cta_textString | nullCall-to-action label, e.g. Shop now.
link_urlString | nullDestination URL.
image_urlsString[]Image URLs from single/multi-image ads and carousel cards.
video_urlsString[]Video URLs (HD when available, otherwise SD).
library_urlStringDirect Ads Library URL for this ad.
snapshotObject | nullCreative payload: images, videos, carousel cards, CTA, page profile.
rawObjectOriginal GraphQL ad object.

snapshot.display_format is typically IMAGE, VIDEO, CAROUSEL, or MULTI_IMAGES. Carousel slides live in snapshot.cards (title, CTA, link, image/video per card).

Media is stored as Facebook CDN URLs, not downloaded files.

Example OUTPUT

{
"adCount": 5,
"pageCount": 5,
"files": [
"ads-by-page.json"
]
}

Example ads-by-page.json

{
"111111111111111": [
{
"ad_archive_id": "755606263512566",
"page_id": "111111111111111",
"page_name": "Example Brand",
"is_active": true,
"start_date": 1735689600,
"end_date": null,
"publisher_platform": ["FACEBOOK", "INSTAGRAM"],
"body_text": "Ad copy…",
"title": "Headline",
"cta_text": "Shop now",
"link_url": "https://example.com/product",
"image_urls": ["https://scontent.xx.fbcdn.net/…"],
"video_urls": ["https://video.xx.fbcdn.net/…"],
"library_url": "https://www.facebook.com/ads/library/?id=755606263512566&country=TW",
"snapshot": {},
"raw": {}
}
]
}

Notes

  • Enable Apify Proxy → Residential. Datacenter IPs are usually blocked by Meta with HTTP 403.
  • The browser does not download ad images, videos, fonts, or Facebook telemetry beacons. Creative URLs are still saved in the output.
  • The library is infinite-scroll. The Actor scrolls until it reaches maxItems, 6 empty rounds, or maxScrollRounds.
  • Meta may show cookie consent or a login wall. Overlays are dismissed when possible, but not guaranteed.
  • Follow the Ads Library terms and local law. Use this only for public transparency data and competitive research.