# LinkedIn Ad Library Scraper - Search & Ad Details (`thenetaji/linkedin-ad-library-scraper`) Actor

Search LinkedIn Ad Library ads by advertiser, payer, creative keyword, served-in country, date range, or impressions. The Actor paginates search results, fetches one ad from its detail URL, and can add details to saved search results.

- **URL**: https://apify.com/thenetaji/linkedin-ad-library-scraper.md
- **Developed by:** [The Netaji](https://apify.com/thenetaji) (community)
- **Categories:** Marketing, Business, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.75 / 1,000 results

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## LinkedIn Ad Library Scraper

The Actor searches LinkedIn Ad Library records by advertiser, paying entity, creative keyword, country, date range, or impression range; it can also retrieve the detail record from a LinkedIn Ad Library detail URL. Search results are paginated until `maxItems` is reached or the source has no further page.

Search records contain `ad_id`, `ad_url`, `thumbnail`, and `is_video`. A detail lookup, or the optional `enrichAdDetails` step on a search, can add `ad_format`, `advertiser`, `advertiser_company_id`, `advertiser_logo`, `paid_for_by`, `run_dates`, `creative_body`, `creative_headline`, `creative_image`, and `total_impressions`. Fields that are not present for an ad are returned as `null`.

### Choosing the workflow

`scraperType` selects one of two workflows:

- `adsSearch` searches the Ad Library. At least one search filter is required. `maxItems` defaults to `50`; `0` removes that item limit.
- `adDetail` retrieves one record from the LinkedIn Ad Library detail URL. The legacy `ad_id` input also accepts a numeric identifier for existing integrations. Search filters, `maxItems`, and `enrichAdDetails` do not apply to this workflow.

The following search retrieves up to 20 cloud-related ads served in the United States and adds details for every saved record:

```json
{
  "scraperType": "adsSearch",
  "keyword": "cloud",
  "countries": "US",
  "maxItems": 20,
  "enrichAdDetails": true
}
```

Paste a detail URL for a direct-detail run:

```json
{
  "scraperType": "adDetail",
  "ad_id": "https://www.linkedin.com/ad-library/detail/1532791186"
}
```

A live direct-detail response returned this subset:

```json
{
  "ad_id": "1532791186",
  "ad_format": "Single Image Ad",
  "advertiser": "Runpod",
  "advertiser_company_id": "80190603",
  "paid_for_by": "Runpod",
  "run_dates": null,
  "creative_headline": "Deploy AI systems on reliable GPU infrastructure.",
  "total_impressions": null
}
```

A separate search response for the same ad included `ad_url` as `https://www.linkedin.com/ad-library/detail/1532791186`, a thumbnail URL, and `is_video: false`. `total_impressions` is present only when LinkedIn provides an impression range. `ad_details_enriched` appears only for search records whose optional detail request succeeded. The add-on is charged only for those successful detail requests.

### Search filters and boundaries

`account_owner` and `company_name` are separate LinkedIn Ad Library filters. `payer` matches the entity named in the ad's `Paid for by` disclosure; `keyword` matches creative text. `countries` accepts one ISO 3166-1 alpha-2 code per run, such as `US`.

`date_option` accepts `last-30-days`, `current-month`, `current-year`, `last-year`, or `custom-date-range`. A custom range requires both `startdate` and `enddate` in `YYYY-MM-DD` form, and the start date cannot be later than the end date. Dates cannot be supplied with another date option.

Each impression boundary is a value-and-unit pair: `impressions_min_value` with `impressions_min_unit`, and `impressions_max_value` with `impressions_max_unit`. Units are `none`, `thousand`, and `million`. When both boundaries are set, the minimum cannot exceed the maximum.

### Related Actors

[LinkedIn Company Scraper](https://apify.com/thenetaji/linkedin-company-scraper) retrieves public company-page data when the required output is company context rather than an advertising record. [LinkedIn Post Scraper](https://apify.com/thenetaji/linkedin-post-scraper) retrieves a known public post, activity, or article when organic post text and reactions are required.

# Actor input Schema

## `scraperType` (type: `string`):

Choose Search Ad Library to use the filters below, or Ad detail to fetch the single LinkedIn Ad Library detail URL above.

## `ad_id` (type: `string`):

Required for Ad detail. Paste the full LinkedIn Ad Library detail URL; a numeric ad ID remains supported for existing integrations. Ignored for Search Ad Library.

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

Maximum ads to save when Search Ad Library is selected. Set 0 for no item limit. Ignored for Ad detail.

## `enrichAdDetails` (type: `boolean`):

For Search Ad Library only: fetch and attach each saved ad's detail record. Each successful detail fetch is charged separately.

## `account_owner` (type: `string`):

LinkedIn Ad Library account-owner name filter.

## `company_name` (type: `string`):

LinkedIn Ad Library company-name filter, separate from Account owner.

## `payer` (type: `string`):

Entity named in the ad's Paid for by disclosure.

## `keyword` (type: `string`):

Text to match in the ad creative.

## `countries` (type: `string`):

Two-letter country code where the ad was served, for example US. One country per run.

## `date_option` (type: `string`):

Preset date range. Custom date range requires both Start date and End date.

## `startdate` (type: `string`):

First day of a Custom date range. Supply End date as well.

## `enddate` (type: `string`):

Last day of a Custom date range. Supply Start date as well.

## `impressions_min_value` (type: `integer`):

Minimum whole-number impression count. Requires a Minimum impressions unit.

## `impressions_min_unit` (type: `string`):

Unit paired with Minimum impressions.

## `impressions_max_value` (type: `integer`):

Maximum whole-number impression count. Requires a Maximum impressions unit.

## `impressions_max_unit` (type: `string`):

Unit paired with Maximum impressions.

## Actor input object example

```json
{
  "scraperType": "adsSearch",
  "ad_id": "https://www.linkedin.com/ad-library/detail/1532791186",
  "maxItems": 20,
  "enrichAdDetails": false,
  "account_owner": "Microsoft",
  "countries": "US"
}
```

# Actor output Schema

## `dataset` (type: `string`):

All records scraped by this run

# 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 = {
    "ad_id": "https://www.linkedin.com/ad-library/detail/1532791186",
    "maxItems": 20,
    "account_owner": "Microsoft",
    "countries": "US"
};

// Run the Actor and wait for it to finish
const run = await client.actor("thenetaji/linkedin-ad-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 = {
    "ad_id": "https://www.linkedin.com/ad-library/detail/1532791186",
    "maxItems": 20,
    "account_owner": "Microsoft",
    "countries": "US",
}

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

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

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

```

## CLI example

```bash
echo '{
  "ad_id": "https://www.linkedin.com/ad-library/detail/1532791186",
  "maxItems": 20,
  "account_owner": "Microsoft",
  "countries": "US"
}' |
apify call thenetaji/linkedin-ad-library-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=thenetaji/linkedin-ad-library-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

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