LinkedIn Ad Library API
Ads in LinkedIn’s public Ad Library by company id, advertiser name, keyword or payer, by country and date, 24 a page with the total count.
GET /v1/linkedin/adsBeta5 credits per callRefunded on failureimport os, requests
res = requests.get(
"https://api.groundsocial.dev/v1/linkedin/ads?company_id=1035",
headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()Response
200 · 5 credits{ "total_count": 11566, "data": [ { "ad_id": "1646882134", "url": "https://www.linkedin.com/ad-library/detail/1646882134", "creative_type": "SPONSORED_STATUS_UPDATE", "format": "Single Image Ad", "advertiser": "Microsoft", "posted_by": null, "commentary": "NIS2 est désormais une priorité opérationnelle, et non un changement futur. Découvrez le dernier rapport d’IDC et ses a…", "headline": "Transformez les exigences de NIS2 en actions" }, { "ad_id": "1698885096", "url": "https://www.linkedin.com/ad-library/detail/1698885096", "creative_type": "SPONSORED_UPDATE_CAROUSEL", "format": "Carousel Ad", "advertiser": "Microsoft", "posted_by": null, "commentary": "Explore the latest developments across AI, cloud and security from Microsoft Ignite, and the opportunities they could op…", "headline": null }, "… 22 more" ], "after": "1697387276-1795170194640"}Parameters
| Name | Type | Description |
|---|---|---|
company_idquery | string | Numeric company ids, comma-separated (up to 10). Example: 1035. |
advertiserquery | string | Advertiser name, as LinkedIn’s own advertiser box takes it. |
keywordquery | string | Words in the ad. |
payerquery | string | Who paid for the ad. |
countriesquery | string | ISO 3166 alpha-2 codes, comma-separated, e.g. US,GB. |
date_optionquery | "last-30-days" | "current-month" | "current-year" | "last-year" | One of last-30-days, current-month, current-year, last-year. |
start_datequery | string | Ads shown on or after (YYYY-MM-DD); with end_date. |
end_datequery | string | Ads shown on or before (YYYY-MM-DD). |
afterquery | string | Cursor: the previous page’s after, with the same filters. |
Response fields
200 with a LinkedInAdsPage, in LinkedIn’s own schema.org JSON-LD, with the rest of the public page beside it.
| Field | Type | Description |
|---|---|---|
total_count | integer | null | |
data | LinkedInAdCard[] | |
after | string | null | Pagination token for the next 24; null on the last page. |
Status codes
| Status | Meaning |
|---|---|
200 | A page of ads. |
400 | Invalid input. Nothing was charged. |
401 | Missing or invalid API key. |
402 | Not enough credits, a spend cap was reached, or payment is required. |
403 | The target is private, or the account is suspended. |
404 | LinkedIn has no such public page, or it was removed. |
429 | Too many requests. Wait for Retry-After seconds. |
503 | LinkedIn is temporarily unavailable. Retryable; nothing was charged. |
Every error has code, message, hint and retryable. All error codes
Questions
Why does it sometimes fail?
The Ad Library turns away some visits; when every attempt is turned away the call answers 503 upstream_unavailable and is never charged. Try again shortly.
LinkedIn is a trademark of LinkedIn Corporation. We are not affiliated with or endorsed by LinkedIn.