Practical Tools
facebook-adsweb-scrapingad-intelligenceapify

How to Scrape Facebook Ad Library Without the API

Scrape Facebook Ad Library without the official API. The Meta API only covers EU political ads — here's how to extract any ad in any country.

To scrape Facebook Ad Library without the official API, use a headless browser or a hosted Apify actor that loads facebook.com/ads/library, scrolls the infinite-scroll feed, and parses the embedded JSON payloads. The Meta Ad Library API is restricted to EU political and social-issue ads only, so any commercial, e-commerce, or non-EU ad data must come from scraping the public web interface directly. The fastest no-code path is the Facebook Ad Library Scraper, which handles rate limiting, pagination, and creative downloads on Apify infrastructure.

Quick Answer

You scrape Facebook Ad Library by sending requests to the public /ads/library/ URL with search parameters (q=, view_all_page_id=, country=, ad_type=all), then extracting the embedded GraphQL response that ships with each page. The official Meta API rejects requests for non-political ads outside the EU, which is why every commercial competitive-intelligence tool — ScrapeCreators, Swipekit, SociaVault — relies on scraping. A working scraper needs three things: rotating residential proxies, a session-token handler for the lsd and jazoest tokens, and a GraphQL response parser. You can build it yourself in ~300 lines of Python with Playwright, or run a hosted actor and pay per result.

Why doesn't the official Facebook Ad Library API work?

Meta's Ad Library API has hard limits that make it useless for most use cases:

  • Geography: Only ads served in the EU are accessible for general categories.
  • Categories: Outside the EU, only ads about social issues, elections, or politics are returned.
  • Authentication: Requires a Facebook Developer account, app review, and identity verification.
  • Fields: No creative media URLs, no landing-page links, no ad copy in many cases.

If you sell DTC products, run an agency, or do competitor research on e-commerce brands, the API returns zero results. That's the whole reason a scraping ecosystem exists — Meta publishes the data on a public web page but won't expose it via API.

Public ad data is the safest category of web data to scrape. Meta launched the Ad Library specifically as a public transparency tool — the URL facebook.com/ads/library works without login, the data is published intentionally, and US courts (hiQ v. LinkedIn, Meta v. Bright Data) have repeatedly affirmed that scraping public pages without bypassing technical access controls is not a CFAA violation.

Caveats worth knowing:

  • Meta's ToS prohibits automated access for logged-in accounts. Stay logged out.
  • Don't republish creative assets in ways that infringe trademark or copyright.
  • Rate-limit yourself. Aggressive scraping triggers IP bans, not lawsuits.

For internal competitive intelligence, swipe files, and market research, scraping the public Ad Library is standard industry practice.

How to scrape Facebook Ad Library step by step

Here's the manual approach if you're building it yourself:

1. Construct the search URL

https://www.facebook.com/ads/library/?
  active_status=active
  &ad_type=all
  &country=US
  &q=protein+powder
  &search_type=keyword_unordered

Key parameters:

  • country=ALL for global results
  • ad_type=all returns commercial ads (the API only allows political_and_issue_ads)
  • view_all_page_id=<page_id> to scrape one specific advertiser
  • media_type=video or image to filter creative

2. Handle the session tokens

Facebook injects lsd, jazoest, and __spin_r tokens on first page load. Without them, GraphQL requests return 400. Use Playwright or Puppeteer to load the page once, scrape the tokens from the HTML, then reuse them for paginated requests.

3. Parse the GraphQL response

The infinite scroll triggers calls to /api/graphql/ with a doc_id like 9333890689959217 (this rotates monthly — pin to whatever's current). The response is JSON with the structure:

data.ad_library_main.search_results_connection.edges[]
  .node.collated_results[]
    .snapshot.body.text       // ad copy
    .snapshot.images[].original_image_url
    .snapshot.videos[].video_hd_url
    .snapshot.link_url        // landing page
    .snapshot.page_name
    .start_date

4. Paginate

Each response includes page_info.end_cursor. Pass it as cursor in the next request until has_next_page is false.

5. Rotate proxies

Datacenter IPs get blocked within ~50 requests. Residential or mobile proxies (Bright Data, Smartproxy, Oxylabs) cost ~$3-8/GB and survive thousands of requests. Budget about 1-2 MB per page of 30 ads.

What's the easiest way to scrape Facebook Ad Library at scale?

Run a managed actor instead of maintaining the scraper yourself. The Facebook Ad Library Scraper on Apify takes a JSON input like:

{
  "searchTerms": ["protein powder", "creatine"],
  "country": "US",
  "adType": "all",
  "maxAds": 500
}

…and returns a dataset with ad copy, page name, start date, full-resolution images, video URLs, landing pages, and platform placement (Facebook, Instagram, Messenger, Audience Network). You pay per result — typically a fraction of a cent per ad — and you don't manage proxies, browsers, or token rotation.

This is the same approach ScrapeCreators and Swipekit use under the hood; the difference is you own the data instead of paying $50–$200/month for a SaaS UI on top.

How do I scrape ads from a specific Facebook page?

Two methods:

Method A — by Page ID:

  1. Visit the brand's Facebook page and grab the numeric ID from the page source (search for "pageID":").
  2. Pass it to the actor as pageIds: ["123456789"] or hit the URL ?view_all_page_id=123456789.

Method B — by page name keyword: Use the standard q= keyword search and filter results by snapshot.page_name post-fetch. This catches ads even if you don't know the exact page ID.

Method A is more reliable — page name searches sometimes miss results when Meta's full-text index is stale.

What data fields can I extract from Facebook Ad Library?

The publicly visible Ad Library snapshot contains roughly 40 fields per ad. The useful ones:

FieldDescription
ad_archive_idUnique ID, dedupe key
page_name / page_idAdvertiser
body.textPrimary ad copy
titleHeadline
cta_text"Shop Now", "Learn More", etc.
link_urlLanding page (often a tracking redirect)
images[] / videos[]Full-res creative URLs
start_date / end_dateRun duration
publisher_platforms[]FB, IG, Messenger, Audience Network
is_activeStill running?
display_formatSingle image, carousel, video, DCO
total_active_timeHow long it's been running (proxy for performance)

total_active_time is the gold field for swipe files — ads running >30 days are almost always profitable winners.

How much does it cost to scrape 10,000 Facebook ads?

Three options compared:

DIY with Playwright + residential proxies:

  • Proxy bandwidth: ~15 GB × $5 = $75
  • Server time: $10
  • Engineering time: 2-5 days to build, ongoing maintenance when Meta changes doc_id
  • Total: $85 + your time

Apify actor (pay-per-use):

  • ~$0.30–$0.50 per 1,000 ads depending on creative downloads
  • Total: $3–$5

SaaS tools (Swipekit, BigSpy, SocialPeta):

  • $49–$299/month flat fee
  • Usually capped at lower volume per query
  • Total: $49+/month

For one-off research, the actor wins on cost. For daily monitoring of 100+ competitors, build a thin wrapper around the actor and store results in your own database.

FAQ

Q: Does scraping Facebook Ad Library require a Facebook account? No. The Ad Library is fully public and works in incognito. In fact, scraping while logged in is a ToS violation — keep your scraper logged out and you stay within the public-data category.

Q: How often does Meta change the Ad Library structure? The user-facing URL has been stable for 4+ years, but the internal GraphQL doc_id rotates roughly every 4–8 weeks. Hosted actors update automatically; DIY scrapers need a maintainer who notices when extractions return zero results.

Q: Can I get ad spend or impression data? Only for political and social-issue ads in supported regions, where Meta publishes spend ranges and impression buckets. Commercial ads show only total_active_time as a performance proxy — longer run = better-performing ad.

Q: What's the difference between scraping the Ad Library and using the Meta Marketing API? The Marketing API gives you data about your own ad accounts — full metrics, conversions, spend. The Ad Library shows every advertiser's publicly visible ads but no performance data. They solve different problems; competitive intel needs the Ad Library.

Q: Can I scrape Instagram-only ads from the Facebook Ad Library? Yes. The Ad Library covers all Meta surfaces. Filter by publisher_platforms containing instagram to isolate Instagram placements, including Reels and Stories ads. There is no separate Instagram ad library to scrape.