# Meta Political Ad Spend Report Exporter (`xyrelith-data/fb-ad-library-spend-report`) Actor

Export Meta Ad Library Report totals, advertiser spending, regional spend and top search keywords for political and issue ads, without login.

- **URL**: https://apify.com/xyrelith-data/fb-ad-library-spend-report.md
- **Developed by:** [Xyrelith Data](https://apify.com/xyrelith-data) (community)
- **Categories:** Social media, Automation, News
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.49 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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

## Meta Political Ad Spend Report Exporter

Export Meta's public **Ad Library Report** for ads about social issues, elections or politics — country spending totals, advertiser leaderboards, regional spend, top spenders per region and the week's most-searched keywords. The report covers Facebook and Instagram political and issue ads published since 2019, in every country where Meta publishes the report. No Facebook account, login or API key is needed.

### What this actor does

- **Six modes:** one full report with selectable sections, plus focused totals, advertiser, region, keyword and spend-tracker modes.
- **Any published market:** 205 country codes, with automatic handling of markets where Meta only publishes the all-dates window.
- **Five date windows:** last day, last 7, last 30, last 90 days or all dates since 2019, ending on any of Meta's seven most recent report dates.
- **Advertiser controls:** server-side name filter, sort by amount spent, number of ads or Page name, and full cursor pagination.
- **Regional depth:** state/region spend, plus the top spenders inside each region from Meta's own per-region report files.
- **Clean rows:** every record carries the country, currency, date window, report date and a `recordType`; empty fields are omitted, so there are no null values to clean up.

### Modes

| Mode | What it returns |
|---|---|
| `report` | The sections selected in `sections` (all five by default). |
| `totals` | Lifetime ad count and spend for each country, plus the selected window's regional spend total. |
| `advertisers` | The spending leaderboard, with filter, sort and pagination. |
| `regions` | Spending for every state/region, with optional top spenders. |
| `keywords` | The week's top Ad Library search phrases in each country. |
| `spendTracker` | A 30- or 90-day spend comparison for Page IDs you supply. |

### Output per record

Every row starts with the same report context:

- `recordType` — `countryTotals`, `advertiser`, `region`, `regionSpender`, `keyword` or `spendTracker`
- `countryCode`, `countryName`, `currency`
- `timeWindow`, `timeWindowTitle`
- `reportDate` — the day the report data ends
- `reportEndDate` — the report date published by Meta
- `periodStartDate`, `periodEndDate` — the inclusive window (omitted for all dates)
- `requestedTimeWindow`, `windowFallback` — present only when Meta could not publish the requested window
- `sourceUrl`, `scrapedAt`

#### Country totals (`recordType: countryTotals`)

- `totalAdsLifetime` — ads in the report since 2019
- `totalSpendLifetime` — lifetime spend in the country's currency
- `windowSpendTotal` — sum of regional spend for the selected window
- `windowSpendIsLowerBound` — present when any region is in Meta's below-floor bucket
- `regionCount`, `advertiserCount`

#### Advertisers (`recordType: advertiser`)

- `rank` — position in the selected sort order
- `pageName`, `pageId`, `pageUrl`, `pageIconUrl`
- `adLibraryUrl` — the advertiser's ads in the Ad Library
- `disclaimer` — the paid-for-by entity
- `amountSpent`, `currency`, `numberOfAds`
- `isDeletedPage` — the Page has been removed from Facebook
- `spendDetails[]` — amount and currency pairs when Meta reports more than one

#### Region spend (`recordType: region`)

- `rank`, `regionName`
- `amountSpent` — numeric spend when Meta discloses an amount
- `amountSpentLabel`, `amountSpentIsFloor` — `≤100` when the region is in Meta's floor bucket

#### Top spenders per region (`recordType: regionSpender`)

- `regionName`, `rank`
- `pageName`, `pageId`, `pageUrl`, `pageIconUrl`, `adLibraryUrl`, `disclaimer`
- `amountSpent`, `amountSpentLabel`, `amountSpentIsFloor`, `currency`
- `numberOfAds` when Meta provides it

#### Keywords (`recordType: keyword`)

- `rank`, `keyword`, `searchUrl`

#### Spend tracker (`recordType: spendTracker`)

- `pageName`, `pageId`, `pageUrl`, `pageIconUrl`, `adLibraryUrl`
- `pageProfileUrl`, `pageLikes`, `verification`
- `amountSpent` — spend in the chosen 30- or 90-day window

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `mode` | select | `report` | `report`, `totals`, `advertisers`, `regions`, `keywords` or `spendTracker` |
| `countries` | multi-select | `["US"]` | One or more of the 205 countries where Meta publishes the report |
| `timeWindow` | select | `last_day` | `last_day`, `last_7_days`, `last_30_days`, `last_90_days` or `all_dates` |
| `reportEndDate` | text | – | Optional `YYYY-MM-DD` end date among Meta's seven most recent report dates |
| `sections` | multi-select | `["totals", "advertisers", "regions", "regionSpenders", "keywords"]` | `totals`, `advertisers`, `regions`, `regionSpenders`, `keywords` (mode=`report`) |
| `advertiserFilter` | text | – | Keep advertisers whose Page name or disclaimer contains this text |
| `sortBy` | select | `spend` | `spend`, `ads` or `page_name` |
| `sortOrder` | select | `desc` | `desc` or `asc` |
| `maxItems` | integer | `5000` | Cap per country per section, 1–100000 |
| `regionSpenderLimit` | integer | `10` | Top spenders returned per region, 1–50 |
| `includeDeletedAdvertisers` | boolean | `true` | Keep deleted Pages and flag them |
| `includeRegionSpenders` | boolean | `true` | In mode=`regions`, also return top spenders |
| `advertiserPageIds` | string list | – | Page IDs or URLs for mode=`spendTracker` |
| `spendTrackerWindow` | select | `last_90_days` | `last_30_days` or `last_90_days` |

### Examples

#### Daily country totals for two markets

```json
{
  "mode": "report",
  "countries": ["US", "GB"],
  "timeWindow": "last_day",
  "sections": ["totals"]
}
```

#### The biggest ad buyers, ranked by number of ads

```json
{
  "mode": "advertisers",
  "countries": ["US"],
  "timeWindow": "last_7_days",
  "sortBy": "ads",
  "sortOrder": "desc",
  "maxItems": 500
}
```

#### Regional spending and top spenders in the UK

```json
{
  "mode": "regions",
  "countries": ["GB"],
  "timeWindow": "last_30_days",
  "includeRegionSpenders": true,
  "regionSpenderLimit": 20
}
```

#### Compare two Pages over 90 days

```json
{
  "mode": "spendTracker",
  "countries": ["US"],
  "advertiserPageIds": ["203805062990264", "2011677365822396"],
  "spendTrackerWindow": "last_90_days"
}
```

### Use cases

- **Journalists and newsrooms** — daily political-spend leaderboards by market.
- **Campaign and advocacy teams** — benchmark spend against allied and opposing Pages.
- **Academic researchers** — build a country-by-country time series of political ad spending.
- **Transparency analysts** — export advertiser, regional and keyword trends in a spreadsheet-ready format.
- **Agencies** — track which advertisers dominate a region before planning a campaign.

### FAQ

#### What ads does the report include?

Only ads about social issues, elections or politics that Meta has classified for the Ad Library Report. Ordinary commercial ads are not part of this report.

#### Do I need a Facebook login or developer account?

No. The actor reads Meta's public report for a logged-out visitor.

#### Do I need to configure a proxy?

No. The actor connects to the public report directly.

#### Why does a row show `≤100` instead of a number?

Meta does not disclose amounts below a small floor. The actor keeps the published bucket in `amountSpentLabel` and marks it with `amountSpentIsFloor` rather than inventing a number.

#### Why did my European country return only `all_dates`?

Some countries publish only the all-dates report. The actor then uses that window and adds `requestedTimeWindow` and `windowFallback` so the change is visible.

#### How fresh is the data?

Meta publishes report dates with a lag. The actor defaults to the latest published date and accepts any of the seven most recent dates.

#### How many advertisers can I get?

Pagination follows Meta's full list up to `maxItems` per country per section. A single US day is about 2,800 advertisers; all dates can be tens of thousands, so raise `maxItems` when you need the complete history.

#### Are deleted Pages included?

Yes by default. Set `includeDeletedAdvertisers` to `false` to drop them; the flag is `isDeletedPage`.

#### Why is an advertiser or region missing from one window?

Meta's report is a snapshot of the selected window and country. A Page that did not run political or issue ads in that window will not appear, and a region with no qualifying spend is omitted.

# Actor input Schema

## `mode` (type: `string`):

`report` returns the sections you select. `totals` returns only lifetime spend and ad totals, `advertisers` the spending leaderboard, `regions` spending by state/region with optional top spenders, `keywords` the week's top Ad Library searches, and `spendTracker` compares named advertisers over 30 or 90 days.

## `countries` (type: `array`):

One or more countries Meta publishes the Ad Library Report for. Each country returns its own totals, advertisers, regions and keywords.

## `timeWindow` (type: `string`):

Reporting window ending on the latest published day. Some EU countries publish only `all_dates`; the actor then uses that longer window and marks the row with `windowFallback`.

## `reportEndDate` (type: `string`):

Optional `YYYY-MM-DD` end date. Meta keeps only the seven most recent report dates; leave blank for the latest published date.

## `sections` (type: `array`):

Which report sections to return. Ignored by the focused modes, except that `regions` can add top spenders through `includeRegionSpenders`.

## `advertiserFilter` (type: `string`):

Only return advertisers whose Page name or disclaimer contains this text. Applies to advertiser and region-spender rows; leave blank for all advertisers.

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

Order of the advertiser leaderboard. `spend` uses Meta's amount spent, `ads` its number of ads in the Library.

## `sortOrder` (type: `string`):

Descending puts the biggest spenders first; ascending reverses the order.

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

Hard cap for each section in each country. Meta publishes about 2,800 US advertisers for a single day and tens of thousands for all dates, so pagination stops at this cap.

## `regionSpenderLimit` (type: `integer`):

How many of each region's highest-spending advertisers to return when the `regionSpenders` section is enabled.

## `includeDeletedAdvertisers` (type: `boolean`):

Keep advertisers whose Facebook Page has been deleted. The `isDeletedPage` field marks them.

## `includeRegionSpenders` (type: `boolean`):

When mode is `regions`, also return the highest-spending advertisers in each region.

## `advertiserPageIds` (type: `array`):

Page IDs, Page URLs or Ad Library URLs to compare. Each row returns the advertiser's spend for the selected tracker window.

## `spendTrackerWindow` (type: `string`):

Comparison window used by the report's spending tracker.

## Actor input object example

```json
{
  "mode": "report",
  "countries": [
    "US"
  ],
  "timeWindow": "last_day",
  "reportEndDate": "",
  "sections": [
    "totals"
  ],
  "advertiserFilter": "",
  "sortBy": "spend",
  "sortOrder": "desc",
  "maxItems": 1,
  "regionSpenderLimit": 10,
  "includeDeletedAdvertisers": true,
  "includeRegionSpenders": true,
  "advertiserPageIds": [],
  "spendTrackerWindow": "last_90_days"
}
```

# Actor output Schema

## `reportRows` (type: `string`):

Dataset containing all exported Meta Ad Library Report records.

# 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 = {
    "mode": "report",
    "countries": [
        "US"
    ],
    "timeWindow": "last_day",
    "reportEndDate": "",
    "sections": [
        "totals"
    ],
    "advertiserFilter": "",
    "sortBy": "spend",
    "sortOrder": "desc",
    "maxItems": 1,
    "regionSpenderLimit": 10,
    "includeDeletedAdvertisers": true,
    "includeRegionSpenders": true,
    "advertiserPageIds": [],
    "spendTrackerWindow": "last_90_days"
};

// Run the Actor and wait for it to finish
const run = await client.actor("xyrelith-data/fb-ad-library-spend-report").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 = {
    "mode": "report",
    "countries": ["US"],
    "timeWindow": "last_day",
    "reportEndDate": "",
    "sections": ["totals"],
    "advertiserFilter": "",
    "sortBy": "spend",
    "sortOrder": "desc",
    "maxItems": 1,
    "regionSpenderLimit": 10,
    "includeDeletedAdvertisers": True,
    "includeRegionSpenders": True,
    "advertiserPageIds": [],
    "spendTrackerWindow": "last_90_days",
}

# Run the Actor and wait for it to finish
run = client.actor("xyrelith-data/fb-ad-library-spend-report").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 '{
  "mode": "report",
  "countries": [
    "US"
  ],
  "timeWindow": "last_day",
  "reportEndDate": "",
  "sections": [
    "totals"
  ],
  "advertiserFilter": "",
  "sortBy": "spend",
  "sortOrder": "desc",
  "maxItems": 1,
  "regionSpenderLimit": 10,
  "includeDeletedAdvertisers": true,
  "includeRegionSpenders": true,
  "advertiserPageIds": [],
  "spendTrackerWindow": "last_90_days"
}' |
apify call xyrelith-data/fb-ad-library-spend-report --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,xyrelith-data/fb-ad-library-spend-report"
        }
    }
}
```

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/IyhY4xwzTHW5fCgW3/builds/MAF88N8BTa3JyGGoT/openapi.json
