Docs menu

LinkedIn Ad Library search

Beta GET /v1/linkedin/ad-library/search

GET /v1/linkedin/ad-library/search

Search the LinkedIn Ad Library by company name, company id or keyword (give at least one). Custom dates need both start_date and end_date, within the past year and ending yesterday at the latest. countries is a comma-separated list; the cursor is LinkedIn's pagination token.

  • Cost: 1 credit
  • Status: Beta. Built and tested against recorded responses; the shape may still gain fields.
  • Cache: Results are kept up to 30 days; send max_age_days to reuse them for free.
  • Timeout: A request still running after about 25 seconds answers 202 with a job to poll (Batch and jobs).

Parameters#

NameTypeRequiredDescription
querystringnoKeyword to search for. Also accepted as keyword, q.
companystringnoAdvertiser name. Also accepted as company_name.
company_idstringnoLinkedIn company id: the number in linkedin.com/company/<id>. Also accepted as companyId.
countriesstringnoComma-separated 2-letter countries, "US,CA,MX".
start_datestringnoStart date, YYYY-MM-DD. Use with end_date. Also accepted as startDate.
end_datestringnoEnd date, YYYY-MM-DD. Use with start_date. Also accepted as endDate.

Every request also accepts:

  • cursor: the cursor from the previous page (Pagination).
  • region: two-letter country code for results that vary by country. Changing it restarts the cursor chain.
  • trim: true for a smaller response without null fields and extra.
  • raw: true to also get the platform's original object as raw.
  • max_age_days: accept a cached result up to this many days old, for 0 credits (Caching).

Example request#

Set your key in the environment first (see Authentication).

curl
curl -G "https://api.socialscrape.io/v1/linkedin/ad-library/search" \
  -H "x-api-key: $SOCIALSCRAPE_API_KEY" \
  --data-urlencode "company=Microsoft"
Python
import os
import requests

params = {
    "company": "Microsoft",
}
res = requests.get(
    "https://api.socialscrape.io/v1/linkedin/ad-library/search",
    headers={"x-api-key": os.environ["SOCIALSCRAPE_API_KEY"]},
    params=params,
)
body = res.json()

if body["ok"]:
    print(body["data"])
else:
    print(body["error"]["code"], body["error"]["message"])
TypeScript
const url = new URL("https://api.socialscrape.io/v1/linkedin/ad-library/search");
url.search = new URLSearchParams({
  "company": "Microsoft"
}).toString();
const res = await fetch(url, {
  headers: { "x-api-key": process.env.SOCIALSCRAPE_API_KEY! },
});
const body = await res.json();

if (body.ok) {
  console.log(body.data);
} else {
  console.error(body.error.code, body.error.message);
}
n8n
{
  "nodes": [
    {
      "name": "SocialScrape LinkedIn Ad Library search",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        0,
        0
      ],
      "parameters": {
        "method": "GET",
        "url": "https://api.socialscrape.io/v1/linkedin/ad-library/search",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "company",
              "value": "Microsoft"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "={{ $env.SOCIALSCRAPE_API_KEY }}"
            }
          ]
        }
      }
    }
  ],
  "connections": {}
}

Example response#

This is a sample from a recorded response, lists and long text are shortened. Status 200.

{
  "ok": true,
  "credits_charged": 1,
  "credits_remaining": 4999,
  "cached": false,
  "cached_at": null,
  "request_id": "req_f73f6d8a73de5b3aee83485a",
  "data": {
    "object": "list",
    "items": [
      {
        "object": "ad",
        "platform": "linkedin",
        "id": "1662766106",
        "url": "https://www.linkedin.com/ad-library/detail/1662766106",
        "advertiser": {
          "object": "advertiser",
          "platform": "linkedin",
          "id": null,
          "name": "Microsoft AI Cloud Partner Program",
          "url": null,
          "page_id": null,
          "country": null,
          "verified": null,
          "ad_count": null,
          "extra": {
            "logo_url": "https://media.licdn.com/dms/image/v2/C560BAQF-MwAnNIx7lQ/company-logo_100_100/company-logo_100_100/0/1630621036154/microsoft_partner_network_logo?e=1795046400&v=beta&t=SZBQn5t9_QMwvmN6bHjuAqWODWScDbTgy1J1v1_PLgA"
          }
        },
        "status": "unknown",
        "started_at": null,
        "ended_at": null,
        "title": "Make each Microsoft 365 Business Premium opportunity a security conversation",
        "body": "Every Microsoft 365 Business Premium opportunity can open a broader security conversation.\n\nIn his latest blog, Diego Be…",
        "cta_text": null,
        "landing_url": null,
        "format": "image",
        "media": {
          "thumbnail_url": null,
          "video_url": null,
          "audio_url": null,
          "image_urls": [
            "https://media.licdn.com/dms/image/v2/D4E10AQHgdQBe1y_lsQ/image-shrink_1280/B4EaF.aXC_HwAc-/0/1793122202032?e=2147483647&v=beta&t=lILQREka0rK8ccXqihFXhxDtktZkTKoOFyYN2S_LEl8"
          ],
          "width": null,
          "height": null
        },
        "regions": null,
        "publisher_platforms": null,
        "impressions": null,
        "spend": null,
        "extra": {
          "ad_type": "Single Image Ad",
          "body_truncated": true,
          "creative_type": "SPONSORED_STATUS_UPDATE",
          "label": "Promoted"
        }
      },
      {
        "object": "ad",
        "platform": "linkedin",
        "id": "1662299216",
        "url": "https://www.linkedin.com/ad-library/detail/1662299216",
        "advertiser": {
          "object": "advertiser",
          "platform": "linkedin",
          "id": null,
          "name": "Microsoft Azure",
          "url": null,
          "page_id": null,
          "country": null,
          "verified": null,
          "ad_count": null,
          "extra": {
            "logo_url": "https://media.licdn.com/dms/image/v2/D560BAQGtwKUNwBubxg/company-logo_100_100/company-logo_100_100/0/1688144190823/microsoft_azure_logo?e=1795046400&v=beta&t=_rNRowQC_y_BHpJH7uH1CjZrO0UtOSxkPzd1kMiZhHg"
          }
        },
        "status": "unknown",
        "started_at": null,
        "ended_at": null,
        "title": "Empiece su prueba de Azure",
        "body": "Conecte dispositivos y datos de forma segura por defecto para que pueda enfocarse en desarrollar, no en defender.",
        "cta_text": null,
        "landing_url": null,
        "format": "video",
        "media": {
          "thumbnail_url": "https://media.licdn.com/dms/image/v2/D5610AQFGHVj1oGbpFA/videocover-high/B56aF_6GPSIsBI-/0/1793147300503?e=2147483647&v=beta&t=724fZOEjF0sGUm5ArcqSVNjyy4UPDVdf9sUy_Bge-ko",
          "video_url": null,
          "audio_url": null,
          "image_urls": null,
          "width": null,
          "height": null
        },
        "regions": null,
        "publisher_platforms": null,
        "impressions": null,
        "spend": null,
        "extra": {
          "ad_type": "Video Ad",
          "creative_type": "SPONSORED_VIDEO",
          "label": "Promoted"
        }
      }
    ],
    "cursor": "eyJrIjoibGlhZHMiLCJ0IjoiMTY2MjEwODk1Ni0xNzkzMTMzODIzOTk4In0",
    "has_more": true,
    "parent": null
  },
  "cursor": "eyJrIjoibGlhZHMiLCJ0IjoiMTY2MjEwODk1Ni0xNzkzMTMzODIzOTk4In0",
  "has_more": true
}

Response#

A list of Ad objects in data.items, with data.cursor and data.has_more.

See Data models for every field. The envelope around data is described in Responses.

Errors#

Failures are free: credits_charged is 0. Branch on error.code, never on the message.

CodeHTTPRetryMeaning
invalid_params400noA parameter is missing, unknown or has the wrong type.
not_found404noThe platform says this profile, post or item does not exist.
upstream_blocked503yesThe platform blocked this fetch; retry (a fresh exit is used).

Every request can also fail with the account and platform errors listed on the Errors page.

Example error:

{
  "ok": false,
  "error": {
    "code": "upstream_blocked",
    "message": "The platform blocked this fetch; retry (a fresh exit is used).",
    "retryable": true
  },
  "credits_charged": 0,
  "request_id": "req_609f66ee93c7eb077915dc40"
}

Also served at#

These paths answer the same request, so code written for other APIs keeps working: /v1/linkedin/ads/search. See Switching from ScrapeCreators.