InsightSocial API
Recipes

Ad library aggregation

Pull the ads a brand is running on Meta, LinkedIn and TikTok in one parallel fan-out and flatten them into one table. 300 to 540 credits per brand.

You will build a competitive-intelligence view of every ad a company is running on Meta (Facebook and Instagram), LinkedIn and TikTok, flattened into one table. Useful for sales-call prep, market research and creative benchmarking.

Cost per run

300 to 540 credits per brand: Meta ad search (100), LinkedIn ad search (100) and TikTok ad search (metered, 100–340). Auditing a 25-company competitive set costs 7,500 to 13,500 credits. Repeating the same search within an hour is free.

How do you list every ad one advertiser has live?

Query each network's public ad library in parallel with the brand name. All three have a search endpoint that takes a name, and the three calls finish together.

Every major ad network publishes a transparency library, but each has its own interface, its own query model and its own response shape, and none of the official interfaces export data.

What you need

EndpointNetworkParametersCredits
GET /v1/facebook/adlibrary/search/adsMeta Ad Libraryquery, optional country, status, media_type, start_date, end_date100
GET /v1/linkedin/ads/searchLinkedIn Ad Librarycompany, keyword or companyId, optional countries, startDate, endDate100
GET /v1/tiktok/adlibrary/searchTikTok Ad Libraryquery or advertiser_name100–340

Three networks, three parameter names

Meta takes query. LinkedIn takes company (or keyword, or companyId) and spells its dates startDate and endDate. TikTok takes query or advertiser_name. A parameter an endpoint does not know is either ignored or rejected with a 400, which is not charged. Check each endpoint's parameters in GET /v1/endpoints before you generalise the call.

The code

The three responses have different shapes, so the script flattens them into {network, ad} rows.

Python
# ad_audit.py
# Pulls the ads a brand is running on three networks in parallel.
# Run with: INSIGHTSOCIAL_API_KEY=isk_live_... python ad_audit.py
import os
from collections import Counter
from concurrent.futures import ThreadPoolExecutor

import requests

KEY = os.environ["INSIGHTSOCIAL_API_KEY"]
BASE = "https://api.insightsocial.app/v1"
BRAND = "Duolingo"

def get(path, **params):
    res = requests.get(f"{BASE}/{path}", params=params,
                       headers={"x-api-key": KEY}, timeout=120)
    return res.json()

LEGS = {
    "meta":     ("facebook/adlibrary/search/ads", {"query": BRAND}),
    "linkedin": ("linkedin/ads/search",           {"company": BRAND}),
    "tiktok":   ("tiktok/adlibrary/search",       {"advertiser_name": BRAND}),
}

with ThreadPoolExecutor(max_workers=3) as pool:
    futures = {net: pool.submit(get, path, **params) for net, (path, params) in LEGS.items()}
    results = {net: f.result() for net, f in futures.items()}

ads, spent = [], 0
for network, body in results.items():
    spent += body.get("credits_used", 0)
    if not body["success"]:
        print(f"{network}: {body['error']['type']} (not charged)")
        continue
    for ad in body["data"].get("items", []):
        ads.append({"network": network, "ad": ad})

print(f'{len(ads)} ads found for "{BRAND}"')
print(dict(Counter(row["network"] for row in ads)))
print(f"credits used: {spent}, remaining: {results['meta'].get('credits_remaining')}")

What you get back

Example output
57 ads found for "Duolingo"
{'meta': 30, 'linkedin': 15, 'tiktok': 12}
credits used: 300, remaining: 9700

The figures are illustrative. Each ad keeps its own network's fields: Meta ads carry the creative text, images, sponsor and running status; LinkedIn ads carry the copy and the advertiser; TikTok ads carry the creative, title, advertiser, impressions and date.

What to change

  • Widen the Meta leg. GET /v1/facebook/adlibrary/search/companies (100) resolves a brand name to its advertiser pages and their pageId. GET /v1/facebook/adlibrary/company/ads (100) then returns one page's full run, which is more precise than a keyword search. GET /v1/facebook/adlibrary/ad/transcript (200) returns what a video ad says out loud.
  • Read one ad in full. GET /v1/facebook/adlibrary/ad, GET /v1/linkedin/ad and GET /v1/tiktok/adlibrary/ad are 100 credits each.
  • Richer TikTok rows. include=ad on the TikTok search adds the brand name, landing page and advertiser profile link to every row.
  • What actually performs. GET /v1/tiktok/ads/top (200–2000) returns TikTok's leaderboard of top ads for a market and time window, with click-through rate and rank. Filter it with keyword to see a category's best creative.
  • Scope by market and date. Add country and start_date / end_date on Meta, and countries and startDate / endDate on LinkedIn.
  • Page deeper. Meta and TikTok page with cursor, LinkedIn with paginationToken. See Pagination.

On this page