Apify example task · whoareyouanas/facebook-ads-library-api
Export Facebook Ads Library search results from a URL
Paste a Facebook Ads Library search URL and export its results. This example exports active image ads for outdoor clothing shown in the United Kingdom, with every filter in the URL kept.
- Actor
- Facebook Ads Library API & Instagram Ads Scraper
- Result limit
- 25 (maxAds)
- Estimated cost
- Up to $0.10
- Run options
- 0.5 GB memory · 300 s timeout
Example updated 2026-11-23 · actor build 0.2.10 · runs in your own Apify account
01 / About the actor
Facebook Ads Library API & Instagram Ads Scraper
Facebook Ads Library API for developers and AI agents. Search Facebook and Instagram ads by keyword, Page ID or Ad Library URL and get ad copy, images, videos, CTAs, landing pages and dates as JSON in seconds. No Meta token, login or proxy setup. Exact ad limits. MCP-ready.
One focused search
Use one keyword, Page ID, or direct search URL per run.
Bound the ad sample
Set maxAds rather than relying on Meta's approximate displayed result count.
Keep creative structure
Review image, video, carousel, and dynamic creative fields in JSON or dataset exports.
02 / Input
The exact input this example runs.
Provide targetUrl, searchQuery, or pageId and set maxAds for the unique-ad cap. Use the documented country, status, media, and date filters where applicable. The current Actor uses built-in proxies and ignores the legacy proxyConfiguration field.
{
"targetUrl": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=GB&media_type=image&q=outdoor%20clothing&search_type=keyword_unordered",
"maxAds": 25
}| Field | Value in this example | What it controls |
|---|---|---|
| targetUrlChange this | "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=GB&media_type=image&q=outdoor%20clothing&search_type=keyword_unordered" | Paste any Meta Ad Library search URL from your browser. It takes precedence over Page ID and keyword, and its filters (country, status, platforms, sort, date range) take precedence over the form. Tracking parameters such as fbclid are removed automatically. To look up one ad by its ID, use our Facebook Ad Library Single Ad Lookup. |
| maxAdsChange this | 25 | Maximum unique ads to deliver in this run, from 1 to 10,000. You pay only for ads delivered, and the run stops exactly at this limit. |
Other inputs you can add (7)
| Field | Type / required | Default | Purpose |
|---|---|---|---|
| searchQuery | string | Not specified | Find ads that mention a keyword, brand or product, for example nike or protein powder. The example searches nike. A URL or Page ID takes precedence when provided. |
| pageId | string | Not specified | Numeric Facebook Page ID of one advertiser, the number after view_all_page_id= in its Ad Library URL. Takes precedence over the keyword example. A search URL takes precedence over this field. |
| country | string | "US" | Two-letter country code where the ads were shown, such as US, GB, IN or DE, or ALL for every country. Used for keyword and Page ID searches. |
| activeStatus | string | "active" | Which ads to return by status. Used for keyword and Page ID searches. Options: active, inactive, all |
| mediaType | string | "all" | Return only ads with this kind of creative. Used for keyword and Page ID searches. Options: all, image, video, meme, none |
| dateFrom | string | Not specified | First day of the range, YYYY-MM-DD. Leave empty for no start limit. |
| dateTo | string | Not specified | Last day of the range, YYYY-MM-DD. Leave empty for no end limit. |
03 / Make it yours
Change these fields for your own research.
01 · targetUrl
Ad Library search URL
Paste any Meta Ad Library search URL from your browser. It takes precedence over Page ID and keyword, and its filters (country, status, platforms, sort, date range) take precedence over the form. Tracking parameters such as fbclid are removed automatically. To look up one ad by its ID, use our Facebook Ad Library Single Ad Lookup.
Example: "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=GB&media_type=image&q=outdoor%20clothing&search_type=keyword_unordered"
02 · maxAds
Maximum ads
Maximum unique ads to deliver in this run, from 1 to 10,000. You pay only for ads delivered, and the run stops exactly at this limit.
Example: 25
Run it in three steps
- Open the example on Apify and select Try for free to copy it into your Apify account.
- Replace the sample values above with your own target and keep the limit small.
- Start the run, then export the dataset as JSON, CSV or Excel.
04 / Output
What the results table shows.
- Rows include ad identity, advertiser, copy, CTA, media references, status, dates, platforms, and adLibraryUrl.
- Unknown status, dates, counts, and durations can be null. A carousel does not by itself establish multiple ad versions.
Columns in the “Ads” view
libraryID
Ad ID
brand
Advertiser
pageId
Page ID
active
Active
body
Ad copy
linkTitle
Headline
ctaText
Call to action
linkUrl
Landing page
format
Format
platforms
Platforms
startDate
Started
endDate
Ended
collaboratorName
Partnership creator
images
Images
videos
Videos
adLibraryUrl
View ad
A view selects columns for the table. The full JSON export keeps every field, including nested arrays and objects.
05 / Cost
What this example costs to run.
At most about $0.10: up to 25 results at $0.004 each (Ad). Fewer results cost less. The live Pricing tab on Apify is authoritative.
Ad
Tiered by Apify plan
Prices checked 2026-11-24. Set a run spending limit in Apify when you widen the input.
06 / API
Run the same input from your code.
This call starts a billable run of Facebook Ads Library API & Instagram Ads Scraper with this example's input and returns the dataset items when it finishes. Synchronous calls wait up to five minutes; for longer runs, POST to /runs instead and read the run's default dataset when it succeeds. Keep the token in an environment variable.
curl --request POST \
'https://api.apify.com/v2/acts/whoareyouanas~facebook-ads-library-api/run-sync-get-dataset-items?format=json' \
--header "Authorization: Bearer $APIFY_TOKEN" \
--header 'Content-Type: application/json' \
--data '{"targetUrl":"https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=GB&media_type=image&q=outdoor%20clothing&search_type=keyword_unordered","maxAds":25}'Coverage & interpretation
Check the result before relying on it.
- Date filters scope the search. Visible creative records do not establish spend, conversions, or ROAS.
- Meta media URLs can expire. One search is not guaranteed to expose every ad or match its approximate result total.
Questions
About this example.
What does the "Export Facebook Ads Library search results from a URL" example collect?
Paste a Facebook Ads Library search URL and export its results. This example exports active image ads for outdoor clothing shown in the United Kingdom, with every filter in the URL kept. It runs Facebook Ads Library API & Instagram Ads Scraper, published by whoareyouanas on Apify.
Which input does this example use?
Ad Library search URL (targetUrl) set to "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=GB&media_type=image&q=outdoor%20clothing&search_type=keyword_unordered"; Maximum ads (maxAds) set to 25. The full JSON input is shown on this page.
How much does it cost to run this example?
At most about $0.10: up to 25 results at $0.004 each (Ad). Fewer results cost less. The live Pricing tab on Apify is authoritative.
How do I change it for my own research?
Open the example on Apify and select Try for free to copy it into your account, then edit Ad Library search URL, Maximum ads. Keep the result limit small for the first run and check the output before scaling up.
Can I run it from the API or on a schedule?
Yes. Send the same JSON input to the Facebook Ads Library API & Instagram Ads Scraper run endpoint with your Apify API token, or save the copied task in your Apify account and add a schedule. Results land in the run's default dataset as JSON, CSV or Excel.
How do I get a search URL?
Open the Meta Ad Library in your browser, choose a country, ad category and keyword or advertiser, apply your filters, then copy the address bar and paste it as the search URL.
Which filters are kept?
Country, active status, media type, platform, language, search type, sort and date range are kept. Tracking parameters such as fbclid or utm_source are ignored and listed in the run summary.
Which export formats are available?
Every run saves a dataset you can download as JSON, CSV, Excel, XML or HTML from the Storage tab or through the Apify API.
More examples
Related tasks you can copy.
View a competitor's Facebook ads by Page ID
View and export the active Facebook and Instagram ads of one competitor, Burger King in the United States, by its Facebook Page ID. Swap in your competitor's Page ID to analyze their creatives.
View exampleDownload Facebook Ad Library videos for a keyword
Collect active video ads for running shoes shown in the United States, with a direct MP4 link, preview image and duration for every video, plus the ad copy and call to action.
View exampleFind Facebook ads that ran in a date range
Search the Meta Ad Library for protein powder ads shown in the United States that ran between November 1 and November 15, 2026. Change the keyword and dates for your own research window.
View exampleFacebook Ads Library product research: 50% off free shipping
Find active ecommerce ads that mention 50% off free shipping in the United States to spot products stores are promoting on Facebook and Instagram. Export offer copy, creatives and store links.
View exampleMeta (Facebook) Ad Library Scraper
Find active Adidas video ads on Meta
Search the US Meta Ad Library for active Adidas video ads. Review available creative URLs, ad copy, calls to action and start dates.
View exampleFacebook Ad Library Video Downloader & Ad Lookup
Check a Meta Ad Library ad by ID
Look up one Facebook or Instagram ad by its Meta Ad Library ID. Check the lookup outcome and active state, then inspect available ad copy and media links.
View exampleGuides