# LinkedIn Ad Library Scraper - Competitor B2B Ads Intel (`viralanalyzer/linkedin-ads-library`) Actor

Scrape LinkedIn Ad Library for competitor ads, creatives, CTAs. No login required. By keyword, company ID, or company URL. B2B advertising intelligence + DSA compliance research.

- **URL**: https://apify.com/viralanalyzer/linkedin-ads-library.md
- **Developed by:** [viralanalyzer](https://apify.com/viralanalyzer) (community)
- **Categories:** Social media, Marketing, Lead generation
- **Stats:** 4 total users, 2 monthly users, 60.9% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 ad scrapeds

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 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 Ad Library Scraper - B2B Competitor Ads Intelligence

> 🔗 [View on Apify Store](https://apify.com/viralanalyzer/linkedin-ads-library) | 🇺🇸 English | [🇧🇷 Português](#português)

Extract competitor B2B ad creatives from **LinkedIn Ad Library** — the public ad transparency archive LinkedIn maintains for **EU DSA compliance** and global ad accountability. **No login, no API key, no OAuth.** HTTP-only scrape of `linkedin.com/ad-library/search`.

### ✨ Features

- **Anonymous access** — no LinkedIn account, no OAuth, no API key
- **3 search modes** — by keyword/brand, by numeric company ID, by company URL
- **Country filter** — ISO codes (US/BR/GB/DE/FR/ES/IT/MX/AR/CL/AU/JP/IN/NL/etc.) or leave empty for all
- **24 ads per query** — LinkedIn's hard limit per search page
- **Lean compute** — pure HTTP + Cheerio (no Playwright), 256MB / 120s default
- **Rich output** — ad ID, creative type (`SPONSORED_STATUS_UPDATE` / `SPONSORED_VIDEO`), advertiser name + URL, logo, headline, ad body, image, detail page link
- **NEVER 0 ITEMS guard** — fails loud with diagnostic (HTML bytes, cards detected, final URL) if LinkedIn rotates schema instead of silently SUCCEED-with-zero
- **B2B-focused** — perfect for SaaS / enterprise / agency competitive intel

### 📥 Input

| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| `searchMode` | enum | Yes | `keyword` | `keyword` / `companyId` / `companyUrl` |
| `query` | string | Yes | `Adobe` | Keyword/brand name, numeric company ID, or LinkedIn company URL |
| `country` | string | No | `` (all) | ISO country code (US/BR/GB/DE/FR/etc.) |
| `maxAdsPerQuery` | int | No | `24` | Max ads to return (LinkedIn hard-caps at 24 per query) |

#### Example input — by keyword
```json
{
  "searchMode": "keyword",
  "query": "Adobe",
  "country": "US",
  "maxAdsPerQuery": 24
}
````

#### Example input — by company URL

```json
{
  "searchMode": "companyUrl",
  "query": "https://www.linkedin.com/company/microsoft",
  "country": "",
  "maxAdsPerQuery": 24
}
```

### 📤 Output

```json
{
  "adId": "1265295783",
  "creativeType": "SPONSORED_STATUS_UPDATE",
  "advertiserName": "Adobe",
  "advertiserUrl": "https://www.linkedin.com/company/adobe",
  "logoUrl": "https://media.licdn.com/dms/image/v2/.../company-logo_100_100/...",
  "headline": "Transform your creative workflow",
  "body": "See how Adobe Firefly accelerates ideation for enterprise teams...",
  "imageUrl": "https://media.licdn.com/dms/image/v2/.../feedshare-shrink_1280/...",
  "detailUrl": "https://www.linkedin.com/ad-library/detail/1265295783",
  "source": "linkedin-ad-library",
  "scrapedAt": "2026-05-16T15:42:00.000Z"
}
```

### 💰 Pricing

**Pay-per-event** — you only pay when a real ad is returned. Zero ads → zero charge. Owner runs (the ViralAnalyzer team itself) are never charged.

### 🚀 Use cases

- **B2B competitive intel** — see which campaigns SaaS / enterprise / agency competitors are running
- **EU DSA compliance research** — LinkedIn maintains this library specifically for Digital Services Act transparency; perfect for academic / regulatory research
- **Creative analysis** — extract winning B2B headline + copy + imagery patterns from top-spending advertisers
- **Brand safety** — discover unauthorized ads using your brand keywords
- **Ad agency benchmarking** — see which creative formats (single image vs. video) competitors prioritize on LinkedIn
- **Recruiting intel** — track competitor employer-brand ads + talent acquisition campaigns

### ⚠️ Common errors

| Error | Cause | Fix |
|---|---|---|
| `[FAIL] Zero ads extracted (htmlBytes < 50000)` | LinkedIn blocked the request or returned empty page | Retry with different proxy region or wait 60s |
| `[FAIL] Zero ads extracted (cardsDetected=0)` | Advertiser has no current ads OR keyword too narrow | Broaden the keyword OR remove `country` filter |
| `[INPUT] companyUrl mode requires linkedin.com/company/<slug>` | URL format invalid | Use full URL like `https://www.linkedin.com/company/adobe` |
| Request retries exhausted | Rare network glitch | Re-run after 60s |

### 🔒 Privacy

- All requests go directly to `linkedin.com/ad-library/search` (public archive)
- No LinkedIn account credentials are sent or stored
- Output contains only ads that LinkedIn itself publishes openly per its EU DSA transparency mandate

### 📚 Related actors

- [Facebook Ad Library Intelligence](https://apify.com/viralanalyzer/facebook-ads-library) — Meta Ad Library (FB / IG / Messenger / WhatsApp ads)
- [Google Ads Transparency](https://apify.com/viralanalyzer/google-ads-transparency) — Google / YouTube / Maps / Shopping ad transparency
- [LinkedIn Intelligence](https://apify.com/viralanalyzer/linkedin-intelligence) — LinkedIn company / job / employee intel

### 🆕 Changelog

- **v1.0** (2026-05-16): Initial release. Three search modes (keyword / companyId / companyUrl), country filter, NEVER 0 ITEMS guard with HTML diagnostics, owner-skip PPE.

***

### Português

## 💼 LinkedIn Ad Library Scraper - Inteligência de Ads B2B

Extrai criativos publicitários B2B de **competidores** da **LinkedIn Ad Library** — arquivo público de transparência publicitária que o LinkedIn mantém para **compliance com a DSA da UE** e accountability global. **Sem login, sem API key, sem OAuth.** Scrape HTTP-only de `linkedin.com/ad-library/search`.

#### ✨ Recursos

- **Acesso anônimo** — sem conta LinkedIn, sem OAuth, sem API key
- **3 modos de busca** — por palavra-chave/marca, por ID numérico da empresa, ou por URL da empresa
- **Filtro de país** — códigos ISO (US/BR/GB/DE/FR/etc.) ou vazio para todos
- **24 ads por consulta** — limite duro do LinkedIn por página de busca
- **Compute leve** — HTTP puro + Cheerio (sem Playwright), 256MB / 120s padrão
- **Output rico** — ID do ad, tipo de criativo, nome + URL do anunciante, logo, headline, corpo, imagem, link de detalhes
- **Guard NEVER 0 ITEMS** — falha alto com diagnóstico se LinkedIn mudou estrutura HTML

#### 💰 Por que vale a pena

- **B2B-first**: LinkedIn é o único arquivo de ads onde tráfego é majoritariamente B2B / SaaS / enterprise
- **Sem fricção**: 0 setup, 0 credenciais — apenas rode
- **Compliance EU DSA**: dados oficiais publicados pelo próprio LinkedIn por mandato regulatório
- **Mais barato que API LinkedIn Marketing**: API oficial exige conta empresarial + approval; aqui é só pay-per-ad

#### 🚀 Casos de uso para o mercado BR/LATAM

- Espiar campanhas B2B SaaS de Stone, Nubank, RD Station, Resultados Digitais
- Pesquisa acadêmica de compliance regulatório (DSA / LGPD)
- Análise criativa — copiar padrões de headline/body dos top spenders B2B
- Inteligência para agências — saber em quais formatos (vídeo vs imagem) os concorrentes apostam
- Inteligência de recrutamento — ads de employer brand de big-techs do BR

#### ⚠️ Erros comuns

| Erro | Causa | Solução |
|---|---|---|
| `Zero ads (htmlBytes < 50000)` | LinkedIn bloqueou o request | Re-rodar após 60s |
| `Zero ads (cardsDetected=0)` | Anunciante sem ads ativos OU termo muito restrito | Ampliar o termo OU remover filtro `country` |
| `companyUrl mode requires...` | URL inválida | Use URL completa `https://www.linkedin.com/company/<slug>` |

# Actor input Schema

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

How to look up ads: by keyword/brand text, by numeric LinkedIn company ID, or by full LinkedIn company URL.

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

Search keyword (e.g. 'Adobe'), company ID (e.g. '1337'), or company URL (e.g. 'https://www.linkedin.com/company/adobe').

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

Optional ISO country code (e.g. 'US', 'BR', 'GB'). Leave empty for all countries.

## `maxAdsPerQuery` (type: `integer`):

LinkedIn returns max 24 ads per query (hard limit).

## Actor input object example

```json
{
  "searchMode": "keyword",
  "query": "Adobe",
  "country": "",
  "maxAdsPerQuery": 24
}
```

# 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 = {
    "searchMode": "keyword",
    "query": "Adobe",
    "maxAdsPerQuery": 24
};

// Run the Actor and wait for it to finish
const run = await client.actor("viralanalyzer/linkedin-ads-library").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 = {
    "searchMode": "keyword",
    "query": "Adobe",
    "maxAdsPerQuery": 24,
}

# Run the Actor and wait for it to finish
run = client.actor("viralanalyzer/linkedin-ads-library").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 '{
  "searchMode": "keyword",
  "query": "Adobe",
  "maxAdsPerQuery": 24
}' |
apify call viralanalyzer/linkedin-ads-library --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "LinkedIn Ad Library Scraper - Competitor B2B Ads Intel",
        "description": "Scrape LinkedIn Ad Library for competitor ads, creatives, CTAs. No login required. By keyword, company ID, or company URL. B2B advertising intelligence + DSA compliance research.",
        "version": "1.0",
        "x-build-id": "4ceogOueySR7vMvMG"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/viralanalyzer~linkedin-ads-library/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-viralanalyzer-linkedin-ads-library",
                "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/viralanalyzer~linkedin-ads-library/runs": {
            "post": {
                "operationId": "runs-sync-viralanalyzer-linkedin-ads-library",
                "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/viralanalyzer~linkedin-ads-library/run-sync": {
            "post": {
                "operationId": "run-sync-viralanalyzer-linkedin-ads-library",
                "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",
                "required": [
                    "searchMode",
                    "query"
                ],
                "properties": {
                    "searchMode": {
                        "title": "Search mode",
                        "enum": [
                            "keyword",
                            "companyId",
                            "companyUrl"
                        ],
                        "type": "string",
                        "description": "How to look up ads: by keyword/brand text, by numeric LinkedIn company ID, or by full LinkedIn company URL.",
                        "default": "keyword"
                    },
                    "query": {
                        "title": "Query",
                        "type": "string",
                        "description": "Search keyword (e.g. 'Adobe'), company ID (e.g. '1337'), or company URL (e.g. 'https://www.linkedin.com/company/adobe')."
                    },
                    "country": {
                        "title": "Country filter (ISO code)",
                        "type": "string",
                        "description": "Optional ISO country code (e.g. 'US', 'BR', 'GB'). Leave empty for all countries.",
                        "default": ""
                    },
                    "maxAdsPerQuery": {
                        "title": "Max ads per query",
                        "minimum": 1,
                        "maximum": 24,
                        "type": "integer",
                        "description": "LinkedIn returns max 24 ads per query (hard limit).",
                        "default": 24
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
