# LinkedIn Ads Scraper (Ad Library) (`khadinakbar/linkedin-ads-scraper`) Actor

Scrape LinkedIn public Ad Library ads by advertiser, payer, keyword, country and date range. Extract ad copy, creatives, advertiser details, payer info and pagination diagnostics. No login or cookies required.

- **URL**: https://apify.com/khadinakbar/linkedin-ads-scraper.md
- **Developed by:** [Khadin Akbar](https://apify.com/khadinakbar) (community)
- **Categories:** Social media, Lead generation, MCP servers
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 1,000 ad founds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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 Ads Scraper - Public Ad Library

Scrape LinkedIn's public Ad Library without a LinkedIn login, cookies, or account risk. The actor searches LinkedIn's public transparency pages and returns structured ad records for competitor intelligence, ad creative research, B2B lead signals, and campaign monitoring.

### What it extracts

Each result can include:

- LinkedIn ad ID and Ad Library detail URL
- Advertiser name, logo, and LinkedIn profile/company URL
- Ad copy, headline, secondary body text, and semantic label
- Creative type and optional human-readable ad format
- Creative image URL and video poster URL when present
- Payer name when detail enrichment is enabled
- Search term, search mode, countries, date filter, page number, and scrape timestamp

### Input

| Field | Description |
| --- | --- |
| `searchTerms` | Advertiser names, payer names, or ad-copy keywords. |
| `query` / `keyword` | Optional single-term aliases for API and MCP callers. |
| `searchMode` | `accountOwner`, `payer`, or `keyword`. |
| `countries` | ISO country codes such as `US`, `GB`, `DE`, or `ALL`. |
| `country` | Optional single country-code alias for API and MCP callers. |
| `dateOption` | `last-30-days`, `current-month`, `current-year`, or `last-year`. |
| `startDate` / `endDate` | Optional custom date range in `YYYY-MM-DD`. |
| `maxResults` | Hard cap on saved and billable ads. |
| `fetchAdDetails` | Fetch detail pages for payer and ad-format enrichment. |
| `outputMode` | `full` or `compact`. |

### Example

```json
{
    "searchTerms": ["monday", "crm software"],
    "searchMode": "accountOwner",
    "countries": ["US", "GB"],
    "dateOption": "last-year",
    "maxResults": 100,
    "fetchAdDetails": true
}
````

### Pricing

This actor uses pay-per-event pricing:

| Event | Price | When charged |
| --- | ---: | --- |
| `apify-actor-start` | $0.00005 | Automatically by Apify when the actor starts |
| `ad-found` | $0.0015 | Each ad saved to the dataset |
| `detail-enriched` | $0.001 | Each detail page fetched when `fetchAdDetails` is enabled |

The actor logs the maximum possible result/detail cost at startup and physically caps charge calls at `maxResults`. The synthetic `apify-actor-start` event is handled by Apify automatically and is not charged manually in the actor code.

### Notes

LinkedIn's public Ad Library includes ads that LinkedIn makes available in its transparency portal. Availability depends on LinkedIn's own disclosure rules, country filters, date windows, and whether the ad remains in the library. The actor only accesses public Ad Library pages and does not use a LinkedIn account.

# Actor input Schema

## `searchTerms` (type: `array`):

Advertiser names, payer names, or ad-copy keywords to search in LinkedIn's public Ad Library. Use focused terms such as competitor names, product categories, or B2B phrases.

## `query` (type: `string`):

Optional single search query alias for API and MCP callers. Ignored when search terms are provided.

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

Optional single keyword alias for API callers. Ignored when search terms or query are provided.

## `searchMode` (type: `string`):

Where LinkedIn should match the search term. Advertiser searches company or advertiser name. Payer searches the entity paying for the ad. Keyword searches ad text and related copy.

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

ISO 3166-1 alpha-2 country codes where ads were served, e.g. US, GB, DE, FR. Use ALL to search all countries. Multiple countries are combined in one LinkedIn search.

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

Optional single ISO country code alias for API and MCP callers. Ignored when countries are provided.

## `dateOption` (type: `string`):

LinkedIn date filter. Ignored when custom start or end dates are provided.

## `startDate` (type: `string`):

Optional custom start date in YYYY-MM-DD format. When set, the actor uses LinkedIn's custom date range filter.

## `endDate` (type: `string`):

Optional custom end date in YYYY-MM-DD format. Use with custom start date to narrow campaign windows.

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

LinkedIn result ordering. Newest first is best for monitoring new competitor ads; oldest first is useful for historical review.

## `maxResults` (type: `integer`):

Hard cap on saved and billable ad records across all searches. Total maximum cost is maxResults x $0.0015, plus detail enrichment if enabled.

## `maxPagesPerSearch` (type: `integer`):

LinkedIn returns about 24 ads per page. This safety cap limits pagination per search term. Raise it for large campaigns or broad keywords.

## `startPaginationToken` (type: `string`):

Optional token from a previous run summary. Use it to resume a single search from a later LinkedIn page.

## `fetchAdDetails` (type: `boolean`):

Fetch each LinkedIn detail page to enrich records with detail-page fields such as ad format, payer name, advertiser profile URL, and fuller copy when available. Slower and charged as an extra detail event per fetched ad.

## `outputMode` (type: `string`):

Full mode keeps all fields. Compact mode keeps the most useful fields for tables, automations, and AI agents.

## `delayMs` (type: `integer`):

Polite delay between LinkedIn pagination requests. Increase for very large runs if LinkedIn responds slowly.

## Actor input object example

```json
{
  "searchTerms": [
    "monday",
    "crm software"
  ],
  "searchMode": "accountOwner",
  "countries": [
    "US"
  ],
  "dateOption": "last-year",
  "sortOrder": "DESCENDING",
  "maxResults": 100,
  "maxPagesPerSearch": 20,
  "fetchAdDetails": false,
  "outputMode": "full",
  "delayMs": 350
}
```

# Actor output Schema

## `ads` (type: `string`):

Dataset items containing LinkedIn Ad Library ads, advertiser fields, creative URLs, search provenance, and optional detail enrichment.

## `summary` (type: `string`):

Run summary including savedCount, stopReason, pagesFetched, nextPaginationToken, request diagnostics, and billing counters.

# 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 = {
    "searchTerms": [
        "monday",
        "crm software"
    ],
    "countries": [
        "US"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/linkedin-ads-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 = {
    "searchTerms": [
        "monday",
        "crm software",
    ],
    "countries": ["US"],
}

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/linkedin-ads-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 '{
  "searchTerms": [
    "monday",
    "crm software"
  ],
  "countries": [
    "US"
  ]
}' |
apify call khadinakbar/linkedin-ads-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "LinkedIn Ads Scraper (Ad Library)",
        "description": "Scrape LinkedIn public Ad Library ads by advertiser, payer, keyword, country and date range. Extract ad copy, creatives, advertiser details, payer info and pagination diagnostics. No login or cookies required.",
        "version": "0.1",
        "x-build-id": "wUZL3OTfMUbBRE5nk"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/khadinakbar~linkedin-ads-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-khadinakbar-linkedin-ads-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/khadinakbar~linkedin-ads-scraper/runs": {
            "post": {
                "operationId": "runs-sync-khadinakbar-linkedin-ads-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/khadinakbar~linkedin-ads-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-khadinakbar-linkedin-ads-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "searchTerms": {
                        "title": "Search terms",
                        "type": "array",
                        "description": "Advertiser names, payer names, or ad-copy keywords to search in LinkedIn's public Ad Library. Use focused terms such as competitor names, product categories, or B2B phrases.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "query": {
                        "title": "Query",
                        "type": "string",
                        "description": "Optional single search query alias for API and MCP callers. Ignored when search terms are provided."
                    },
                    "keyword": {
                        "title": "Keyword",
                        "type": "string",
                        "description": "Optional single keyword alias for API callers. Ignored when search terms or query are provided."
                    },
                    "searchMode": {
                        "title": "Search mode",
                        "enum": [
                            "accountOwner",
                            "payer",
                            "keyword"
                        ],
                        "type": "string",
                        "description": "Where LinkedIn should match the search term. Advertiser searches company or advertiser name. Payer searches the entity paying for the ad. Keyword searches ad text and related copy.",
                        "default": "accountOwner"
                    },
                    "countries": {
                        "title": "Countries",
                        "type": "array",
                        "description": "ISO 3166-1 alpha-2 country codes where ads were served, e.g. US, GB, DE, FR. Use ALL to search all countries. Multiple countries are combined in one LinkedIn search.",
                        "default": [
                            "US"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "country": {
                        "title": "Country",
                        "type": "string",
                        "description": "Optional single ISO country code alias for API and MCP callers. Ignored when countries are provided."
                    },
                    "dateOption": {
                        "title": "Date range",
                        "enum": [
                            "last-30-days",
                            "current-month",
                            "current-year",
                            "last-year"
                        ],
                        "type": "string",
                        "description": "LinkedIn date filter. Ignored when custom start or end dates are provided.",
                        "default": "last-year"
                    },
                    "startDate": {
                        "title": "Custom start date",
                        "type": "string",
                        "description": "Optional custom start date in YYYY-MM-DD format. When set, the actor uses LinkedIn's custom date range filter."
                    },
                    "endDate": {
                        "title": "Custom end date",
                        "type": "string",
                        "description": "Optional custom end date in YYYY-MM-DD format. Use with custom start date to narrow campaign windows."
                    },
                    "sortOrder": {
                        "title": "Sort order",
                        "enum": [
                            "DESCENDING",
                            "ASCENDING"
                        ],
                        "type": "string",
                        "description": "LinkedIn result ordering. Newest first is best for monitoring new competitor ads; oldest first is useful for historical review.",
                        "default": "DESCENDING"
                    },
                    "maxResults": {
                        "title": "Maximum ads",
                        "minimum": 1,
                        "maximum": 5000,
                        "type": "integer",
                        "description": "Hard cap on saved and billable ad records across all searches. Total maximum cost is maxResults x $0.0015, plus detail enrichment if enabled.",
                        "default": 100
                    },
                    "maxPagesPerSearch": {
                        "title": "Maximum pages per search",
                        "minimum": 1,
                        "maximum": 250,
                        "type": "integer",
                        "description": "LinkedIn returns about 24 ads per page. This safety cap limits pagination per search term. Raise it for large campaigns or broad keywords.",
                        "default": 20
                    },
                    "startPaginationToken": {
                        "title": "Start pagination token",
                        "type": "string",
                        "description": "Optional token from a previous run summary. Use it to resume a single search from a later LinkedIn page."
                    },
                    "fetchAdDetails": {
                        "title": "Fetch ad detail pages",
                        "type": "boolean",
                        "description": "Fetch each LinkedIn detail page to enrich records with detail-page fields such as ad format, payer name, advertiser profile URL, and fuller copy when available. Slower and charged as an extra detail event per fetched ad.",
                        "default": false
                    },
                    "outputMode": {
                        "title": "Output mode",
                        "enum": [
                            "full",
                            "compact"
                        ],
                        "type": "string",
                        "description": "Full mode keeps all fields. Compact mode keeps the most useful fields for tables, automations, and AI agents.",
                        "default": "full"
                    },
                    "delayMs": {
                        "title": "Delay between pages (ms)",
                        "minimum": 0,
                        "maximum": 5000,
                        "type": "integer",
                        "description": "Polite delay between LinkedIn pagination requests. Increase for very large runs if LinkedIn responds slowly.",
                        "default": 350
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
