100 free credits. No credit card required. Get a key

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 failure
import 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

NameTypeDescription
company_idquerystringNumeric company ids, comma-separated (up to 10). Example: 1035.
advertiserquerystringAdvertiser name, as LinkedIn’s own advertiser box takes it.
keywordquerystringWords in the ad.
payerquerystringWho paid for the ad.
countriesquerystringISO 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_datequerystringAds shown on or after (YYYY-MM-DD); with end_date.
end_datequerystringAds shown on or before (YYYY-MM-DD).
afterquerystringCursor: 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.

FieldTypeDescription
total_countinteger | null
dataLinkedInAdCard[]
afterstring | nullPagination token for the next 24; null on the last page.
Status codes
StatusMeaning
200A page of ads.
400Invalid input. Nothing was charged.
401Missing or invalid API key.
402Not enough credits, a spend cap was reached, or payment is required.
403The target is private, or the account is suspended.
404LinkedIn has no such public page, or it was removed.
429Too many requests. Wait for Retry-After seconds.
503LinkedIn 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.