# LinkedIn Ad Library Scraper (`unseenuser/linkedin-ads`) Actor

Bulk-export ads from the LinkedIn Ad Library by company, keyword, or company ID.

- **URL**: https://apify.com/unseenuser/linkedin-ads.md
- **Developed by:** [Unseen User](https://apify.com/unseenuser) (community)
- **Categories:** Social media, Lead generation, Automation
- **Stats:** 2 total users, 1 monthly users, 85.7% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$10.00 / 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.

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 (Apify)

Apify actor that scrapes the [LinkedIn Ad Library](https://www.linkedin.com/ad-library/) via the [ScrapeCreators](https://scrapecreators.com) API.

### Disclosure

**This is an independent, community-built tool.** It is not affiliated with, endorsed by, or sponsored by LinkedIn Corporation or Microsoft Corporation.

The scraper accesses the publicly available [LinkedIn Ad Library](https://www.linkedin.com/ad-library/) through the third-party [ScrapeCreators](https://scrapecreators.com) API. The actor's maintainer supplies the ScrapeCreators credits used by every run — end users provide no API key.

**Use responsibly.** Make sure your use complies with:

- [LinkedIn's Terms of Service](https://www.linkedin.com/legal/user-agreement) and ad library usage rules
- Applicable data-protection laws (GDPR in the EU, CCPA in California, etc.) — the data you scrape may include personal data of advertisers
- Your jurisdiction's rules on automated data collection and competitive intelligence

The maintainer provides this tool **as-is, without warranty**, and is not liable for how it's used. If LinkedIn changes its public Ad Library or ScrapeCreators changes its API, this scraper may break without notice.

### How it works

Wraps two endpoints:

- `GET /v1/linkedin/ads/search` — search by company / keyword / companyId / countries / date range, paginated.
- `GET /v1/linkedin/ad` — full details for a single ad.

The ScrapeCreators API key is baked into the actor. End users provide no key. To rotate it, set the `SCRAPE_CREATORS_API_KEY` environment variable on the actor's Apify settings page (overrides the baked-in value).

### Input

| Field | Type | Description |
| --- | --- | --- |
| `companies` | string[] | Bulk-search by company name — one search per value (e.g. `["microsoft","apple"]`). |
| `keywords` | string[] | Bulk-search by keyword — one search per value. |
| `companyIds` | string[] | Bulk-search by numeric LinkedIn company ID. |
| `countries` | string[] | ISO-2 codes applied to every search (e.g. `["US","CA"]`). Empty = all. |
| `startDate` | string | `YYYY-MM-DD`. Datepicker in the UI. |
| `endDate` | string | `YYYY-MM-DD`. Datepicker in the UI. |
| `maxResults` | integer | Global cap across all searches. Default `100`. |
| `fetchAdDetails` | boolean | Fetch full ad page (headline, CTA, URL, targeting…) per result. Default `false`. |
| `adUrls` | string[] | Optional list of `linkedin.com/ad-library/detail/<id>` URLs. When set, skips search and only fetches details. |

Provide at least one value across `companies`, `keywords`, `companyIds`, or `adUrls`. Each value in `companies` / `keywords` / `companyIds` triggers its own search; filters and `maxResults` apply globally and ad IDs are deduped across searches.

### Example input

```json
{
    "companies": ["microsoft", "apple", "google"],
    "keywords": ["ai"],
    "countries": ["US"],
    "startDate": "2024-01-01",
    "endDate": "2024-12-31",
    "maxResults": 200,
    "fetchAdDetails": true
}
````

Details-only:

```json
{
    "adUrls": [
        "https://www.linkedin.com/ad-library/detail/664291126",
        "https://www.linkedin.com/ad-library/detail/823975056"
    ]
}
```

### Output

One normalised record per ad is pushed to the default dataset. Columns are emitted in a stable order optimised for browsing in the Apify dataset UI:

| Column | Meaning |
| --- | --- |
| `id` | LinkedIn ad ID |
| `adLibraryUrl` | Derived link back to `linkedin.com/ad-library/detail/<id>` |
| `advertiser` | Advertiser name |
| `poster` | Account that posted the ad |
| `headline` | Ad headline (only with `fetchAdDetails` or details-only mode) |
| `description` | Ad body text |
| `cta` | Call-to-action label |
| `destinationUrl` | Click-through URL |
| `adType` | e.g. "Single Image Ad", "Video Ad" |
| `image` | Creative URL |
| `startDate` / `endDate` | ISO timestamps |
| `adDuration` | Human-readable run duration |
| `targetingLocation` / `targetingLanguage` / `targetingAudience` | Flattened targeting |
| `advertiserLinkedinPage` | Link to advertiser's LinkedIn company page |
| `posterTitle` / `promotedBy` | Posting metadata |
| `_searchedByField` / `_searchedByValue` | Which bulk query surfaced this ad (e.g. `company` / `microsoft`) |
| `_sourceUrl` | Set in details-only mode — the URL you passed in |
| `_scrapedAt` | ISO timestamp when the record was written |

Any new fields returned by ScrapeCreators are appended after the known columns (future-proof). Search-only runs leave detail-only columns empty — enable `fetchAdDetails` for the rich record above.

### Running locally

```bash
npm install
## create storage/key_value_stores/default/INPUT.json with your input
npm start
```

Requires Node.js 20+.

### Links

- ScrapeCreators LinkedIn Ads search: <https://docs.scrapecreators.com/v1/linkedin/ads/search>
- ScrapeCreators LinkedIn Ad details: <https://docs.scrapecreators.com/v1/linkedin/ad/>

### Disclaimer

This actor is provided **"AS IS", WITHOUT WARRANTY OF ANY KIND**, express or implied, including (but not limited to) the warranties of merchantability, fitness for a particular purpose, accuracy, and non-infringement.

**No liability.** In no event shall the maintainer or contributors be liable for any claim, damages, or other liability — whether in an action of contract, tort, or otherwise — arising from, out of, or in connection with this actor, the data it returns, or the use of either.

**No guarantee of completeness or accuracy.** The data returned by this scraper is sourced from LinkedIn's public Ad Library via a third-party API (ScrapeCreators). Results may be incomplete, outdated, inaccurate, reordered, rate-limited, or unavailable at any time. Do not rely on this scraper as a source of truth for legal, financial, regulatory, investment, or any other critical decisions.

**Intellectual property.** All advertisements, trademarks, logos, creatives, copy, and likenesses returned by this scraper are the property of their respective advertisers, LinkedIn, or other rights holders. You are solely responsible for using the scraped data in a manner that respects those rights — including copyright, trademark, publicity, and privacy rights.

**Data protection.** Scraped records may include personal data (names, job titles, company affiliations). If you process this data, you are the data controller under applicable laws (GDPR, UK GDPR, CCPA, LGPD, etc.) and you alone are responsible for lawful basis, notices, retention, and subject-rights handling.

**Availability.** LinkedIn and/or ScrapeCreators may change, restrict, throttle, or discontinue the underlying public Ad Library and API at any time without notice. The scraper may stop working, return different fields, or return different data as a result. The maintainer is under no obligation to provide updates, fixes, or support.

**Compliance is your responsibility.** By using this actor, you confirm that your use complies with: [LinkedIn's User Agreement](https://www.linkedin.com/legal/user-agreement) and related LinkedIn policies; [ScrapeCreators' Terms](https://scrapecreators.com) (where applicable); and all laws applicable to you, your users, and the individuals whose data you process.

**Not legal advice.** Nothing in this README, the input form, or any message associated with this actor constitutes legal advice. Consult a qualified lawyer in your jurisdiction before relying on the scraper for any use that may carry legal risk.

**Permitted use.** This tool is intended for lawful competitive research, market intelligence, and ad creative inspiration. Do not use it for scraping personal profiles, building spam databases, impersonation, harassment, fraud, or any purpose prohibited by the platforms referenced above or by law.

**By using this actor you acknowledge and accept the terms of this disclaimer.** If you do not accept these terms, do not run the actor.

# Actor input Schema

## `companies` (type: `array`):

One or more company names. Each name triggers a separate search — great for scraping multiple brands in one run.

## `keywords` (type: `array`):

Words or phrases to search for. Each keyword triggers its own search.

## `companyIds` (type: `array`):

Optional. Numeric LinkedIn company IDs — useful when a company name is ambiguous. Each ID triggers its own search.

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

Only include ads targeted at these countries. Use 2-letter ISO codes (e.g. US, CA, GB). Leave empty for all countries. Applied to every search.

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

Only include ads that ran on or after this date.

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

Only include ads that ran on or before this date.

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

Global cap across all searches. The scraper pages through results automatically until this cap is hit.

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

For every ad, also fetch the full ad page — headline, description, destination URL, CTA, targeting info, etc. Slower and roughly 2x the cost.

## `adUrls` (type: `array`):

Optional. Paste LinkedIn ad URLs (https://www.linkedin.com/ad-library/detail/<id>). When filled, the scraper skips search and only fetches details for these URLs.

## Actor input object example

```json
{
  "companies": [
    "microsoft"
  ],
  "keywords": [],
  "companyIds": [],
  "countries": [],
  "maxResults": 100,
  "fetchAdDetails": false,
  "adUrls": []
}
```

# 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 = {
    "companies": [
        "microsoft"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("unseenuser/linkedin-ads").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 = { "companies": ["microsoft"] }

# Run the Actor and wait for it to finish
run = client.actor("unseenuser/linkedin-ads").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 '{
  "companies": [
    "microsoft"
  ]
}' |
apify call unseenuser/linkedin-ads --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "LinkedIn Ad Library Scraper",
        "description": "Bulk-export ads from the LinkedIn Ad Library by company, keyword, or company ID.",
        "version": "0.0",
        "x-build-id": "p55mx8ptAFGm3kDrN"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/unseenuser~linkedin-ads/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-unseenuser-linkedin-ads",
                "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/unseenuser~linkedin-ads/runs": {
            "post": {
                "operationId": "runs-sync-unseenuser-linkedin-ads",
                "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/unseenuser~linkedin-ads/run-sync": {
            "post": {
                "operationId": "run-sync-unseenuser-linkedin-ads",
                "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": {
                    "companies": {
                        "title": "Company names",
                        "type": "array",
                        "description": "One or more company names. Each name triggers a separate search — great for scraping multiple brands in one run.",
                        "items": {
                            "type": "string"
                        },
                        "default": []
                    },
                    "keywords": {
                        "title": "Keywords",
                        "type": "array",
                        "description": "Words or phrases to search for. Each keyword triggers its own search.",
                        "items": {
                            "type": "string"
                        },
                        "default": []
                    },
                    "companyIds": {
                        "title": "LinkedIn company IDs",
                        "type": "array",
                        "description": "Optional. Numeric LinkedIn company IDs — useful when a company name is ambiguous. Each ID triggers its own search.",
                        "items": {
                            "type": "string"
                        },
                        "default": []
                    },
                    "countries": {
                        "title": "Countries",
                        "type": "array",
                        "description": "Only include ads targeted at these countries. Use 2-letter ISO codes (e.g. US, CA, GB). Leave empty for all countries. Applied to every search.",
                        "items": {
                            "type": "string"
                        },
                        "default": []
                    },
                    "startDate": {
                        "title": "Start date",
                        "type": "string",
                        "description": "Only include ads that ran on or after this date."
                    },
                    "endDate": {
                        "title": "End date",
                        "type": "string",
                        "description": "Only include ads that ran on or before this date."
                    },
                    "maxResults": {
                        "title": "Max ads to return",
                        "minimum": 1,
                        "maximum": 100000,
                        "type": "integer",
                        "description": "Global cap across all searches. The scraper pages through results automatically until this cap is hit.",
                        "default": 100
                    },
                    "fetchAdDetails": {
                        "title": "Include full ad details",
                        "type": "boolean",
                        "description": "For every ad, also fetch the full ad page — headline, description, destination URL, CTA, targeting info, etc. Slower and roughly 2x the cost.",
                        "default": false
                    },
                    "adUrls": {
                        "title": "Ad URLs",
                        "type": "array",
                        "description": "Optional. Paste LinkedIn ad URLs (https://www.linkedin.com/ad-library/detail/<id>). When filled, the scraper skips search and only fetches details for these URLs.",
                        "items": {
                            "type": "string"
                        },
                        "default": []
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
