# Facebook Ad Library Scraper | Ads, Creatives & Spend (`genial_candlestand/facebook-ads-library-scraper`) Actor

Get Meta Ad Library ads with advertiser page, ad text, landing page, CTA, images, videos, dates and platforms; political ads add spend and impressions. Search by keyword, page ID or URL with country, category, media, platform and date filters. Optional EU reach and targeting. No login.

- **URL**: https://apify.com/genial_candlestand/facebook-ads-library-scraper.md
- **Developed by:** [Flowo](https://apify.com/genial_candlestand) (community)
- **Categories:** Social media, Lead generation, Automation
- **Features:** Limited permissions
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.60 / 1,000 ads

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Facebook Ad Library Scraper | Ads, Creatives & Spend

![Facebook Ad Library Scraper | Ads, Creatives & Spend](https://api.apify.com/v2/key-value-stores/Ll7RrWtDkZYOrBvfE/records/facebook-com-ad-library-ad-transparency-banner-44bd4ce4.png)

Search the public Meta Ad Library and get one row per ad: the advertiser page name, the ad text and headline, the landing page link, the call-to-action button, image and video URLs, carousel cards, start and end dates and the platforms the ad runs on. Political and issue ads also come with spend, impressions and the "Paid for by" line, and an optional add-on adds EU/UK reach, targeted age, gender and locations. No Facebook login or cookies are needed.

### What does Facebook Ad Library Scraper do?

You give it search terms, numeric advertiser page IDs or Ad Library search URLs, plus filters such as country, ad category, active status, media type, platforms, languages and start dates. It returns every matching ad from the Meta Ad Library (Facebook, Instagram, Messenger, Threads, WhatsApp and Audience Network) as a flat row you can export to JSON, CSV or Excel. It is built for marketers and agencies doing competitor creative research, e-commerce teams looking for ads that work, and researchers and journalists who follow political ads.

### How to scrape the Facebook Ad Library

![How Facebook Ad Library Scraper works: Opens the public Meta Ad Library search for each term, page ID or URL; Reads the first 30 ads and the total count from the search page; Loads the next pages 10 a](https://api.apify.com/v2/key-value-stores/Ll7RrWtDkZYOrBvfE/records/facebook-com-ad-library-ad-transparency-how-91b21a3a.png)

1. Open the actor in Apify Console.
2. Enter one or more **Search terms** (e.g. `running shoes`), or **Advertiser page IDs** (e.g. `15087023444` for Nike), or paste **Ad Library URLs** copied from facebook.com/ads/library.
3. Pick a **Country** (`US`, `DE`, an English country name, or `ALL`) and, if you want, the ad category, active status, media type, platforms, languages, start dates and sort order.
4. Set **Max ads per search** (default 100) and, optionally, **Max ads in total**.
5. Turn on **Add ad details** if you need EU/UK reach and targeting.
6. Click **Start**. Rows appear in the dataset page by page while the run is going; export them when it finishes.

### How much does it cost to scrape the Facebook Ad Library?

Price per event by Apify plan:

| Event | Free | Bronze | Silver | Gold and above |
|---|---|---|---|---|
| Ad | $0.70 per 1,000 | $0.665 per 1,000 | $0.63 per 1,000 | $0.595 per 1,000 |
| Add-on: ad details | $0.30 per 1,000 | $0.285 per 1,000 | $0.27 per 1,000 | $0.255 per 1,000 |
| Actor start | $0.00005 | $0.00005 | $0.00005 | $0.00005 |

A test run with the API example input below returned 40 rows in 8 s.

You pay per ad saved to the dataset (the `ad` event, $0.0007 per ad = $0.70 per 1,000 ads on the Free plan). With **Add ad details** on, each ad whose details came back adds the `ad-details` event ($0.0003 per ad = $0.30 per 1,000). Every run also has a start fee of $0.00005.

Not charged: searches that find no ads, ads cut off by your limits (`maxItemsPerQuery` and `maxItems` are exact, so you never pay for extra ads), and details that failed to load.

| Scenario | Events | Cost on the Free plan |
|---|---|---|
| One search term, default limit (100 ads) | 100 `ad` | $0.07005 |
| 10 search terms × 100 ads | 1,000 `ad` | $0.70005 |
| 500 EU ads with details | 500 `ad` + 500 `ad-details` | $0.50005 |
| Count only: 10 searches with `maxItemsPerQuery: 1` | 10 `ad` | $0.00705 |

### Input

![Facebook Ad Library Scraper input example: Search terms, Exact phrase, Country, Ad category, Active status, Media type, Sort by](https://api.apify.com/v2/key-value-stores/Ll7RrWtDkZYOrBvfE/records/facebook-com-ad-library-ad-transparency-input-35ad65fe.png)

At least one of `queries`, `pageIds` or `startUrls` is needed; you can combine them. Searches run one after another: first the search terms, then the page IDs, then the URLs.

| Field | What it does |
|---|---|
| `queries` | Search terms, one search per term, matched in ad text and advertiser names. |
| `exactPhrase` | Match each term as an exact phrase. Applies to `queries` only. |
| `pageIds` | Numeric advertiser page IDs, e.g. `15087023444` — the `view_all_page_id` from an Ad Library URL. Page URLs or names are not accepted. |
| `startUrls` | Ad Library search URLs with `country=` and `ad_type=`. Used as they are; the form filters do not apply to them. Single-ad links (`?id=…`) are not supported. |
| `country` | A 2-letter code in any case (`US`, `de`), an English country name, or `ALL` (default). |
| `adType` | `all` (default), `political_and_issue_ads`, `housing_ads`, `employment_ads`, `credit_ads`, `financial_products_and_services_ads`. Housing, employment, credit and financial need a country in the EU/EEA, UK, Switzerland, US or Canada (not `ALL`). |
| `activeStatus` | `active` (default), `inactive` or `all`. |
| `mediaType` | `all` (default), `image`, `video`, `meme`, `image_and_meme`, `none` (no image or video). |
| `publisherPlatforms` | Any of `facebook`, `instagram`, `messenger`, `threads`, `whatsapp`, `audience_network`. Empty = all. |
| `contentLanguages` | 2-letter ISO 639-1 codes, e.g. `en`, `es`. Empty = all. |
| `startDateFrom` / `startDateTo` | The ad started running in this range (YYYY-MM-DD). The start day must not be in the future or after the end day; a future end day means no upper limit. |
| `sortBy` | `relevance` (default) or `impressions` (most impressions first). |
| `maxItemsPerQuery` | Exact limit per search (default 100). |
| `maxItems` | Exact limit for the whole run (empty = none). |
| `includeDetails` | The paid details add-on (EU/UK reach, targeting, payer/beneficiary, advertiser info). |
| `proxyConfiguration` | Residential proxy by default; needed for more than about 30 ads per search. |

Example input:

```json
{
  "queries": ["nike"],
  "country": "US",
  "sortBy": "impressions",
  "startDateFrom": "2026-10-01",
  "startDateTo": "2026-10-31",
  "publisherPlatforms": ["instagram"],
  "contentLanguages": ["en"],
  "maxItemsPerQuery": 40
}
```

### What data can you extract from the Facebook Ad Library?

![Facebook Ad Library Scraper output example: Image, Advertiser, Ad text, Headline](https://api.apify.com/v2/key-value-stores/Ll7RrWtDkZYOrBvfE/records/facebook-com-ad-library-ad-transparency-output-4c67160a.png)

| Group | Fields |
|---|---|
| Ad and search | `adArchiveId`, `url`, `query`, `searchType` (`keyword`, `page` or `url`), `searchCountry`, `position`, `totalResultsCount` (50001 means "50,000+") |
| Advertiser page | `pageId`, `pageName`, `pageProfileUrl`, `pageProfilePictureUrl`, `pageLikeCount`, `pageCategories` |
| Status and dates | `isActive`, `startDate`, `endDate` (ISO 8601), `publisherPlatforms` (e.g. `FACEBOOK`, `INSTAGRAM`), `displayFormat` (e.g. `IMAGE`, `VIDEO`, `CAROUSEL`, `DCO`, `DPA`) |
| Creative | `bodyText`, `title`, `linkUrl`, `linkDescription`, `caption`, `ctaText`, `ctaType`, `imageUrl`, `imageUrls`, `videoUrls`, `videoPreviewImageUrl`, `cards` (title, bodyText, linkUrl, imageUrl, videoUrl, ctaText per card), `cardsCount` |
| Versions and flags | `collationCount`, `collationId`, `categories`, `containsSensitiveContent`, `containsDigitalCreatedMedia` |
| Political and issue ads | `byline`, `spend`, `spendMin`, `spendMax`, `currency`, `impressions`, `impressionsMin`, `impressionsMax`, `reachEstimate`, `advertiserPhone`, `advertiserEmail`, `advertiserWebsite`, `advertiserAddress` |
| Details add-on | `pageAbout`, `pageVerification`, `pageCategory`, `pageInstagramUsername`, `pageInstagramFollowers`, `payerBeneficiary`, `targetsEu`, `euTotalReach`, `ukTotalReach`, `targetGender`, `targetAgeMin`, `targetAgeMax`, `targetLocations`, `reachByCountry` |
| Run | `scrapedAt` |

A real row from a `nike` search in the US (image URLs shortened):

```json
{
  "adArchiveId": "1550534860016399",
  "url": "https://www.facebook.com/ads/library/?id=1550534860016399",
  "query": "nike",
  "searchType": "keyword",
  "searchCountry": "US",
  "position": 1,
  "totalResultsCount": 25456,
  "pageId": "115939511520844",
  "pageName": "Perfect themes",
  "pageProfileUrl": "https://www.facebook.com/100093512920259/",
  "pageLikeCount": 18553,
  "pageCategories": ["Topic"],
  "isActive": true,
  "startDate": "2026-05-19T07:00:00.000Z",
  "endDate": "2026-11-13T08:00:00.000Z",
  "publisherPlatforms": ["FACEBOOK", "INSTAGRAM", "AUDIENCE_NETWORK", "MESSENGER", "THREADS"],
  "displayFormat": "IMAGE",
  "bodyText": "🔥🍭Themepack is a FREE and personalized APP😍 various styles of Theme💎 、Weather💖、Photo😊、Clock、Calendar to pick any widget to dress up your home screen！",
  "title": "𝕊𝕦𝕡𝕖𝕣 𝕙𝕠𝕥 𝕨𝕚𝕕𝕘𝕖𝕥𝕤 𝕒𝕡𝕡 ！",
  "linkUrl": "http://play.google.com/store/apps/details?id=com.iconchanger.widget.theme.shortcut",
  "linkDescription": null,
  "caption": "play.google.com",
  "ctaText": "Install now",
  "ctaType": "INSTALL_MOBILE_APP",
  "imageUrl": "https://scontent-man2-1.xx.fbcdn.net/v/t39.35426-6/700927950_…_n.jpg?…&oe=6AFCD83A",
  "videoUrls": [],
  "cards": [],
  "cardsCount": 0,
  "collationCount": null,
  "categories": ["UNKNOWN"],
  "containsSensitiveContent": false,
  "containsDigitalCreatedMedia": false,
  "spend": null,
  "impressions": null,
  "advertiserEmail": null,
  "scrapedAt": "2026-11-13T11:02:12.912Z"
}
```

### Use cases

- **Competitor creative research:** search `running shoes` or `protein powder` in the US and collect the ad copy, creatives, landing pages and start dates of every advertiser.
- **All ads of one advertiser:** pass a page ID such as `15087023444` with `country: ALL` and `activeStatus: all` to get the whole ad history of that page, with the total count.
- **Political ad monitoring:** search `climate` with `adType: political_and_issue_ads` to get spend, impressions, the "Paid for by" line and advertiser contacts.
- **EU transparency and targeting:** search `adidas` in `DE` with `includeDetails` to get EU reach, reach by country, targeted age, gender and locations, and payer/beneficiary.
- **Market sizing:** run many terms with `maxItemsPerQuery: 1` and read `totalResultsCount` for each.

### Limitations

- Only the fields `adArchiveId`, `url`, `query`, `searchType`, `searchCountry`, `position` and `scrapedAt` are always filled. Every other field can be `null` or an empty list when Meta does not show it, e.g. `bodyText` and `linkDescription` on some ads, `collationCount`/`collationId` when an ad has no versions, `videoUrls` and `videoPreviewImageUrl` on non-video ads, `cards` on single-creative ads.
- Spend, impressions, reach estimate, `byline` and the advertiser phone, email, website and address exist only for political and issue ads. Commercial ads have them as `null`.
- `spend` is shown in the currency Meta picks for the viewer, as a range string; `spendMin`/`spendMax` are parsed from it. `impressionsMax` is `null` for values like ">1M".
- The details fields are absent unless `includeDetails` is on. EU/UK reach exists only for ads shown in the EU or UK.
- Dynamic product ads (`DPA`, `DCO`) can keep Meta templates such as `{{product.name}}` in `title` or `bodyText`; the real products are in `cards`.
- Image and video URLs are signed by Facebook and expire after some time (`oe=` parameter). Download them soon if you need the files.
- `totalResultsCount` is capped by Meta at 50001 ("50,000+").
- There is no Facebook follower count (the source has page likes and, with details, Instagram followers), no contacts for commercial advertisers, and no "only new ads" mode.
- Search by Facebook page URL or name is not supported; use the numeric page ID from an Ad Library URL.

### Tips and troubleshooting

- **Only about 30 ads per search?** Meta rate-limits the next pages on datacenter IPs. Keep the default residential proxy for more than about 30 ads per search; the run warns you when the proxy is not residential.
- **Run failed with an input error?** The actor checks every value before it sends a request, because Meta silently swaps bad values (a wrong country becomes the visitor's country, a missing `ad_type` becomes political ads). Fix the field named in the message — e.g. use a supported country for housing, employment, credit or financial ads, or add `country=` and `ad_type=` to a pasted URL.
- **0 rows?** The run succeeds with a warning that Meta has no ads for the search. Try `activeStatus: all`, a wider country (`ALL`) or remove the media, platform, language and date filters.
- **Only new ads:** schedule the actor with `startDateFrom` set to the last run day.
- **Form filters ignored?** They do not apply to `startUrls`; the URL runs exactly as pasted. `exactPhrase` applies only to `queries`.
- **Same ad twice?** An ad found by two different searches gives one row per search, each with its own `query`.

### API, MCP and integrations

Run the actor from your code with the same JSON input as in Console. Your API token is in [Console → Settings → API & Integrations](https://console.apify.com/settings/integrations).

**Python** (`pip install apify-client`):

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("genial_candlestand/facebook-ads-library-scraper").call(run_input={"queries": ["nike"], "country": "US", "maxItemsPerQuery": 40})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

**Node.js** (`npm install apify-client`):

```js
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('genial_candlestand/facebook-ads-library-scraper').call({"queries": ["nike"], "country": "US", "maxItemsPerQuery": 40});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

**HTTP** — one request runs the actor and returns the results (runs up to 5 minutes; longer ones: [run asynchronously](https://docs.apify.com/api/v2/act-runs-post)):

```bash
curl -X POST "https://api.apify.com/v2/acts/genial_candlestand~facebook-ads-library-scraper/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"queries":["nike"],"country":"US","maxItemsPerQuery":40}'
```

**AI agents (MCP).** Add the actor as a tool of the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp). Claude Code:

```bash
claude mcp add --transport http apify "https://mcp.apify.com?tools=genial_candlestand/facebook-ads-library-scraper"
```

Claude Desktop, Cursor or VS Code: `{"mcpServers": {"apify": {"url": "https://mcp.apify.com?tools=genial_candlestand/facebook-ads-library-scraper"}}}`. Then ask, for example:

- "Find active Facebook and Instagram ads mentioning running shoes in the US, 100 ads"
- "Get all ads of Facebook page 15087023444 in all countries, active and inactive"
- "List US political ads about climate with spend, impressions and who paid for them"

**Integrations.** Run it on a schedule with [Apify Schedules](https://docs.apify.com/platform/schedules) and send the results to Google Sheets, Slack, Zapier, Make, n8n or your webhook — see [Apify integrations](https://docs.apify.com/platform/integrations).

### FAQ

**Do I need a Facebook account or API token?**<br>
No. The actor reads the public, logged-out Ad Library and uses no login, cookies or token.

**Which platforms are covered?**<br>
Whatever the Meta Ad Library shows: Facebook, Instagram, Messenger, Threads, WhatsApp and Audience Network. Filter them with `publisherPlatforms`; each row lists them in `publisherPlatforms`.

**How do I find an advertiser's page ID?**<br>
Open the advertiser's ads in the Ad Library in your browser and copy the number after `view_all_page_id=` in the URL, or paste that whole URL into `startUrls`.

**Can I get ad spend for normal (commercial) ads?**<br>
No. Meta publishes spend and impressions only for political and issue ads. For ads shown in the EU or UK, the details add-on gives reach, reach by country and targeting instead.

**How is it different from other Facebook ads actors?**<br>
It takes search terms, page IDs and URLs with validated filters, so a bad value fails with a clear message instead of returning a different search. Limits are exact, rows are saved page by page during the run, political spend and impressions are also parsed into numbers, and each row carries the Meta result count of its search (`totalResultsCount`). The price is $0.70 per 1,000 ads, while the most-used Facebook ads actor in the Store lists $5.80 per 1,000.

**Is it legal to scrape the Facebook Ad Library?**<br>
The Ad Library is a public transparency archive that Meta publishes for anyone to view without logging in, and the actor collects only what it shows publicly. You are responsible for how you use the data, including copyright in the creatives and data protection rules for any personal data, such as the advertiser contacts of political ads.

### Also useful

- [Google Ads Transparency Scraper](https://apify.com/genial_candlestand/google-ads-transparency-scraper) — check the same advertiser's Google ads: formats, dates shown and political spend
- [Google Search Scraper](https://apify.com/genial_candlestand/google-search-results-scraper) — see which text ads competitors run on Google search results for your keywords
- [Instagram Profile Scraper](https://apify.com/genial_candlestand/instagram-profile-details-scraper) — get the followers, bio and links of the advertisers' Instagram accounts
- [TikTok Hashtag, Sound & Place Scraper](https://apify.com/genial_candlestand/tiktok-hashtag-sound-place-scraper) — research the same campaign hashtags on TikTok: posts and their stats

# Actor input Schema

## `queries` (type: `array`):

Keywords searched in ad text and advertiser names, one per line, e.g. running shoes. Each term is one search with the filters below. Give search terms, advertiser page IDs or Ad Library URLs (or several of them).

## `exactPhrase` (type: `boolean`):

Match each search term as an exact phrase (Meta's "exact phrase" search) instead of any of its words. Applies to queries only.

## `pageIds` (type: `array`):

Numeric Facebook page IDs of advertisers, one per line, e.g. 15087023444 (Nike) — copy the view_all_page_id from an Ad Library URL. Returns all ads of the page with the filters below. Page URLs or names (facebook.com/nike) are not accepted.

## `startUrls` (type: `array`):

Search URLs copied from facebook.com/ads/library; they must contain country= and ad_type=. They run exactly as pasted: the filters of this form do not apply to them. Single-ad links (?id=…) are not supported.

## `country` (type: `string`):

Where the ads were shown: a 2-letter country code in any case (US, de, GB…), an English country name, or ALL for all countries. Housing, employment, credit and financial categories need a country in the EU/EEA, UK, Switzerland, US or Canada (not ALL).

## `adType` (type: `string`):

Which ads to search. All ads is every advertiser; Political and issue ads include spend, impressions and the "Paid for by" advertiser contacts. Housing, Employment, Credit and Financial need a country in the EU/EEA, UK, Switzerland, US or Canada.

## `activeStatus` (type: `string`):

Only ads that are running now (Meta's default), only ads that stopped, or both.

## `mediaType` (type: `string`):

Only ads with this kind of creative.

## `publisherPlatforms` (type: `array`):

Only ads shown on any of these platforms. Empty = all platforms.

## `contentLanguages` (type: `array`):

Only ads in any of these languages, as 2-letter ISO 639-1 codes, e.g. en, es. Empty = all languages.

## `startDateFrom` (type: `string`):

Only ads that started running on or after this day (YYYY-MM-DD). Must not be in the future.

## `startDateTo` (type: `string`):

Only ads that started running on or before this day (YYYY-MM-DD). Must not be before "Started running from"; a future day means no upper limit.

## `sortBy` (type: `string`):

Order of the results: Meta's relevance order, or the ads with the most impressions first.

## `maxItemsPerQuery` (type: `integer`):

Stop each search (term, page ID or URL) after exactly this many ads. Set 1 to get only the result count (totalResultsCount) of a search. More than about 30 per search needs the residential proxy.

## `maxItems` (type: `integer`):

Stop the whole run after this many ads across all searches. Empty = no total limit.

## `includeDetails` (type: `boolean`):

One extra request per ad: EU/UK reach, reach by country, targeted age, gender and locations, payer and beneficiary, advertiser about text, verification and Instagram followers. Charged only per ad whose details came back. Reach exists only for ads shown in the EU/UK.

## `proxyConfiguration` (type: `object`):

Residential proxy is needed for more than about 30 ads per search: Meta rate-limits the next pages on datacenter IPs.

## Actor input object example

```json
{
  "queries": [
    "nike"
  ],
  "exactPhrase": false,
  "pageIds": [],
  "startUrls": [],
  "country": "US",
  "adType": "all",
  "activeStatus": "active",
  "mediaType": "all",
  "sortBy": "relevance",
  "maxItemsPerQuery": 100,
  "includeDetails": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset with all ads (overview view)

## `allFields` (type: `string`):

Dataset with every field of every ad

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "queries": [
        "nike"
    ],
    "pageIds": [],
    "startUrls": [],
    "country": "US",
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("genial_candlestand/facebook-ads-library-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "queries": ["nike"],
    "pageIds": [],
    "startUrls": [],
    "country": "US",
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("genial_candlestand/facebook-ads-library-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "queries": [
    "nike"
  ],
  "pageIds": [],
  "startUrls": [],
  "country": "US",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call genial_candlestand/facebook-ads-library-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,genial_candlestand/facebook-ads-library-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/Sz7XUDqfxXyNnl8he/builds/dBlc2X1bl2LpAeACo/openapi.json
