Facebook Ad Library scraper: how to get ads as JSON/CSV (API, Python, no code)
Collect public ads from the Meta Ad Library by keyword, advertiser Page ID or Ad Library link: ad text, headline, landing page, button, images and videos, dates, platforms and version count, plus spend and reach ranges where Meta publishes them. This guide shows the output fields, a working input, and
Python, JavaScript and cURL code for the Actor v0iddo/facebook-ads-library-scraper on Apify.
Open Facebook Ad Library scraper on Apify
What data you get
One row per result. Every row can be downloaded as JSON, CSV, Excel or HTML, or read through the API.
| Field | Label | Type | Example |
|---|---|---|---|
adArchiveId | Ad ID | text | 1550534860016399 |
pageName | Advertiser | text | Perfect themes |
isActive | Active | true/false | true |
startDate | Started | date | 2026-05-19 |
endDate | Ended | date | |
platforms | Platforms | list | ["facebook", "instagram", "audience_network"] |
body | Ad text | text | |
title | Headline | text | ππ¦π‘ππ£ ππ π₯ π¨πππππ₯π€ ππ‘π‘ οΌ |
ctaText | Button | text | Install now |
linkUrl | Landing page | URL | http://play.google.com/store/apps/details?id=com.iconchanger.widget... |
displayFormat | Format | text | IMAGE |
imageUrls | Images | list | ["https://scontent-lga3-1.xx.fbcdn.net/v/t39.35426-6/700927950_9333... |
adLibraryUrl | Ad Library link | URL | https://www.facebook.com/ads/library/?id=1550534860016399 |
pageId | text | 115939511520844 | |
pageCategories | list | ["Topic"] | |
pageLikeCount | number | 18620 | |
searchedFor | text | nike | |
searchCountry | text | US |
Input example
This is the input that is pre-filled on the Actor page. Change the values for your own run.
{
"searchTerms": [
"nike"
],
"country": "US",
"activeStatus": "active",
"maxItems": 20
}
| Input field | Type | What it does |
|---|---|---|
searchTerms | array | Words to search the Ad Library for, for example a brand or product name. |
pageIds | array | Numeric Facebook Page IDs of advertisers whose ads you want, one per line. |
adLibraryUrls | array | Optional search links copied from the browser, such as https://www.facebook.com/ads/library/?activestatus=active&adtype=all&country=US&q=nike&searchtype=keywordunordered. |
country | string | Where the ads were shown: a two-letter country code such as US, GB or DE, or ALL for every country. |
activeStatus | string | Which ads to return: ads that are running now, ads that stopped, or both. |
adType | string | Ad category in the Ad Library. |
mediaType | string | Only ads that contain this kind of media. |
startDateMin | string | Optional. Only ads that started running on or after this date, as YYYY-MM-DD. |
startDateMax | string | Optional. Only ads that started running on or before this date, as YYYY-MM-DD. |
maxAdsPerSearch | integer | The most ads to read for each search term, Page ID or link. |
maxItems | integer | The run stops after this many result rows. |
Output sample
Real rows from a run of the Actor. Fields that name people are left out of the sample.
[
{
"adArchiveId": "1550534860016399",
"adLibraryUrl": "https://www.facebook.com/ads/library/?id=1550534860016399",
"pageId": "115939511520844",
"pageName": "Perfect themes",
"pageCategories": [
"Topic"
],
"pageLikeCount": 18620,
"isActive": true,
"startDate": "2026-05-19",
"platforms": [
"facebook",
"instagram",
"audience_network"
],
"title": "ππ¦π‘ππ£ ππ π₯ π¨πππππ₯π€ ππ‘π‘ οΌ",
"linkUrl": "http://play.google.com/store/apps/details?id=com.iconchanger.widget.theme.shortcut",
"ctaText": "Install now",
"displayFormat": "IMAGE",
"imageUrls": [
"https://scontent-lga3-1.xx.fbcdn.net/v/t39.35426-6/700927950_933331229664450_6487763311056032772_n.jpg?_nc_cat=111&ccb=1-7&_nc_sid=c53f8f..."
],
"searchedFor": "nike",
"searchCountry": "US"
},
{
"adArchiveId": "962050096457659",
"adLibraryUrl": "https://www.facebook.com/ads/library/?id=962050096457659",
"pageId": "156405867784232",
"pageName": "Depop",
"pageCategories": [
"Shopping"
],
"pageLikeCount": 98483,
"isActive": true,
"startDate": "2026-05-22",
"platforms": [
"facebook",
"instagram",
"messenger"
],
"title": "LOFT Women's Blouse",
"linkUrl": "http://itunes.apple.com/app/id518684914",
"linkDescription": "Download Depop - Buy & Sell Clothes by Depop Ltd on the App Store. See screenshots, ratings and reviews, user tips, and more apps like De...",
"ctaText": "Download",
"displayFormat": "DPA",
"imageUrls": [
"https://scontent-lga3-2.xx.fbcdn.net/v/t39.35426-6/706277483_2044031086227797_898989708800947064_n.jpg?_nc_cat=101&ccb=1-7&_nc_sid=c53f8f...",
"https://scontent-lga3-3.xx.fbcdn.net/v/t39.35426-6/706317255_2037222576909248_2490268264375552452_n.jpg?_nc_cat=106&ccb=1-7&_nc_sid=c53f8...",
"https://scontent-lga3-3.xx.fbcdn.net/v/t39.35426-6/706277043_1509973367377594_8218495971134332071_n.jpg?_nc_cat=106&ccb=1-7&_nc_sid=c53f8..."
],
"searchedFor": "nike",
"searchCountry": "US"
}
]
Code: Python, JavaScript and cURL
Get your API token in Apify Console under Settings, then Integrations. The Actor id is v0iddo/facebook-ads-library-scraper.
Python (apify-client)
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run_input = {'searchTerms': ['nike'], 'country': 'US', 'activeStatus': 'active', 'maxItems': 20}
run = client.actor("v0iddo/facebook-ads-library-scraper").call(run_input=run_input)
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
print(item)
JavaScript (apify-client)
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const input = {
"searchTerms": [
"nike"
],
"country": "US",
"activeStatus": "active",
"maxItems": 20
};
const run = await client.actor('v0iddo/facebook-ads-library-scraper').call(input);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
cURL
curl -X POST "https://api.apify.com/v2/acts/v0iddo~facebook-ads-library-scraper/run-sync-get-dataset-items" \
-H "Authorization: Bearer YOUR_APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"searchTerms": ["nike"], "country": "US", "activeStatus": "active", "maxItems": 20}'
Ready-to-run example scripts: example repository on GitHub.
Price
$0.50 per 1,000 results. You pay per result row. There is no separate charge per run. Higher Apify plans pay less per result, down to $0.35 per 1,000. See the pricing tab for your plan. A new Apify account gets $5 of platform credit every month.
Good to know
- Reads the public Meta Ad Library only (facebook.com/ads/library). It opens the Ad Library page in a real browser, as a visitor who is not logged in, and scrolls down so the page loads more ads. No...
- If Meta shows a login, verification or CAPTCHA page instead of the Ad Library, the run stops and says so; it never tries to get around that.
- Not affiliated with Meta. The data is what the public Ad Library shows to a visitor who is not logged in.
- The Ad Library shows about 30 ads first and about 10 more each time the page is scrolled, so large searches take a few minutes. Each search term, Page ID or link is read up to Ads per search (at...
FAQ
What data does the Facebook Ad Library scraper return?
Each result is one row in an Apify dataset. Fields include adArchiveId, pageName, isActive, startDate, endDate, platforms, body, title, and more. The table above shows every field with an example value.
How do I use the Facebook Ad Library scraper from Python?
Install the apify-client package, create a client with your Apify API token, call the Actor v0iddo/facebook-ads-library-scraper with an input like the one above, and read the rows from the run's dataset. The Python snippet above does exactly that.
Can I use it without writing code?
Yes. Open the Actor page on Apify, fill in the input form (an example is already filled in), press Start, and download the results as JSON, CSV, Excel or HTML. You can also schedule runs there.
How much does it cost?
$0.50 per 1,000 results. You pay per result row. There is no separate charge per run. Higher Apify plans pay less per result, down to $0.35 per 1,000. A new Apify account gets $5 of platform credit every month.
How do I limit the number of results?
Set the maxItems input field to the number of results you need; the run stops there, so it also caps the cost of one run. You can also set a maximum cost for a run in the run options on Apify, and the run stops when it is reached.
Can I send the results to Google Sheets, Make, Zapier or n8n?
Yes. Apify datasets connect to Google Sheets, Slack, Make, Zapier and n8n, and a webhook can call your own service when a run finishes. You can also export the dataset as JSON, CSV or Excel.
Open Facebook Ad Library scraper on Apify
Related guides
- Eventbrite Event Data Scraper: Collect public Eventbrite events for any city or online: name, start and end, venue and city, online flag,...
- Eventbrite Scraper: Search Eventbrite events by keyword and location.
- Pracuj.pl Scraper: Scrape Polish job postings from pracuj.pl: title, company, workplaces and address, salary per contract type...