For AI

Meta Ad Library API: ad search, ad details, advertisers

3 Meta Ad Library endpoints covering ads and advertisers, from $0.004 a call. No Meta Ad Library account or cookie needed.

Start free Try Meta Ad Library search
Connect your AI

Paste this into your agent

Read https://okdata.online/agents.md and set up okdata for me; my key is in the OKDATA_API_KEY environment variable.

Claude Code, Cursor, Codex and other agents that can open a link set themselves up from it.

MCP serverhttps://api.okdata.online/mcp

Ask about Meta Ad Library from Claude, Cursor and other agents: the Meta Ad Library MCP page

Endpoints
3 endpoints
In 2 groups, one response format
Lowest price
From $0.004
A call, paid from a prepaid balance
Freshness
Live
Read from the platform when you call
Monthly fee
$0
No subscription or minimum spend

Every Meta Ad Library endpoint

One row per endpoint: the request, what comes back and what one call costs.

Ads

2

Advertisers

1

Prices are per call unless marked /item. A call that reached the data source is charged even when it comes back empty or fails.

What people do with Meta Ad Library data

Each job has its own page with the endpoints it takes, a worked run and its cost.

Start in three steps

The example is Meta Ad Library search; every Meta Ad Library endpoint is called the same way and answers in the same shape.

  1. Get a key

    Create an account and a key in the console. A new key comes with $0.10 to try, no card.

    Open the console

  2. Connect your AI, or call it yourself

    Paste this sentence into Claude Code, Cursor, Codex or another agent that can open a link, and it sets itself up. Or send the request below with your key in the Authorization header.

    Set up okdata for me by following https://okdata.online/agents.md. Here is my okdata API key: okd_…. Keep it safe and use it for all okdata calls.

    Swap the placeholder for your own key, or sign in and copy it with the key filled in.

  3. Make the first call

    Items arrive in data.items (one object in data.item), the next page in page.next_cursor and what you were charged in meta.billing.amount.

    cURL

    curl -G "https://api.okdata.online/v1/meta/ads/search" \
      -H "Authorization: Bearer $OKDATA_API_KEY" \
      --data-urlencode 'query=portable espresso'

    Python

    import os
    import requests
    
    resp = requests.get(
        "https://api.okdata.online/v1/meta/ads/search",
        headers={"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"},
        params={"query": "portable espresso"},
        timeout=60,
    )
    body = resp.json()
    if body["code"] != "ok":
        raise RuntimeError(f"{body['code']}: {body['message']} (charged: {body['charged']})")
    
    for row in body["data"]["items"]:
        print(row["advertiser"]["name"], row["first_shown_at"], row["text"][:60])
    print("cost: $" + body["meta"]["billing"]["amount"])

    TypeScript

    const url = new URL('https://api.okdata.online/v1/meta/ads/search');
    url.searchParams.set('query', "portable espresso");
    
    const res = await fetch(url, {
      headers: {
        Authorization: `Bearer ${process.env.OKDATA_API_KEY}`,
      },
    });
    const body = await res.json();
    if (body.code !== 'ok') throw new Error(`${body.code}: ${body.message}`);
    
    for (const row of body.data.items) {
      console.log(row.advertiser.name, row.first_shown_at, row.text.slice(0, 60));
    }
    console.log('cost: $' + body.meta.billing.amount);

    MCPtools/call

    {
      "name": "call",
      "arguments": {
        "capability": "meta.ads.search",
        "query": "portable espresso"
      }
    }

Questions about the Meta Ad Library API

What does the Meta Ad Library API cost?

Each of the 3 endpoints has its own price, $0.004 a call; the cheapest is Meta Ad Library ad detail at $0.004. You pay per call from a prepaid balance, with no subscription. A call that reaches the data source is charged even when it comes back empty, not found or failed; one stopped before that, such as for bad parameters, is free.

Do I need a Meta Ad Library account or cookie?

No. You call https://api.okdata.online with one okdata key and get public Meta Ad Library data back; no Meta Ad Library account, cookie or QR login is involved.

How fresh is the data?

Every endpoint reads Meta Ad Library at the moment you call; nothing is served from an old copy.

Can my AI agent use the Meta Ad Library API?

Yes. Connect the MCP server at https://api.okdata.online/mcp: its find tool lists these 3 endpoints with their prices, and its call tool runs them on your key.

Can I try it for free?

New accounts get $0.10 of trial credit with no card: enough for 25 calls to Meta Ad Library ad detail.

Connect once, then just ask.

Every new key comes with $0.10 to try it. One sentence connects your agent.

Start free
Connect your AI

Paste this into your agent

Read https://okdata.online/agents.md and set up okdata for me; my key is in the OKDATA_API_KEY environment variable.

Claude Code, Cursor, Codex and other agents that can open a link set themselves up from it.

MCP serverhttps://api.okdata.online/mcp