# Search TikTok Ad Library

> Ads shown in the EU, the UK, Switzerland and Turkey that match a keyword or an advertiser, 12 per page.

- **Request:** `GET https://api.lurkapi.com/v1/tiktok/ad-library/search`
- **Auth:** `x-api-key` header ([get a free key](https://lurkapi.com/login?next=/dashboard))
- **Cost:** 1 credit per call. Validation errors, `401`/`402`/`429` rejections and `5xx` failures are free; `not_found` is charged ([how charging works](https://lurkapi.com/docs.md#credits)).
- **MCP tool:** `tiktok_ad_library_search` on `https://api.lurkapi.com/mcp`
- **Freshness:** responses are cached for up to 1 hour
- **Try it live:** https://lurkapi.com/docs/tiktok/ad-library-search#try (no signup)
- **Platform:** [TikTok](https://lurkapi.com/docs/tiktok.md) (tiktok.com)
- **Web page:** https://lurkapi.com/docs/tiktok/ad-library-search

## When to use this

Use it to see what a brand or a category advertises on TikTok: each ad with its advertiser, caption, video or images, when it ran and roughly how many people saw it. This is TikTok's Ad Library under the EU Digital Services Act, so it only has ads shown in the EU/EEA, Switzerland, the UK and Turkey. Ads shown only in the US or elsewhere aren't in it.

Search by `query`, a keyword matched against ad text and advertiser names (so resellers show up too), or by `advertiser_name` for one advertiser's ads, spelled as the library shows it (e.g. `NIKE Retail B.V.`, as in a result's `advertiser_name`). Results are ads shown in the last 30 days, most relevant first. `region` narrows them to one country; an ad that ran in several countries appears under each.

**Pagination.** 12 ads per page. Pass the response's `cursor` back as `cursor` (with the same params) for more; `has_more` is false at the end. For keyword searches `total` stops counting at 5,000.

An `advertiser_name` the library doesn't know returns 404 `not_found`, with close matches in the message.

## Parameters

All parameters go in the query string.

| Name | Type | Required | Default | Allowed values | Description | Example |
| --- | --- | --- | --- | --- | --- | --- |
| `query` | string | no |  |  | Keyword, e.g. `running shoes`. Pass this or `advertiser_name`. | `running shoes` |
| `advertiser_name` | string | no |  |  | One advertiser's name as the library shows it, e.g. `NIKE Retail B.V.` Pass this or `query`. |  |
| `region` | string | no | `all` | `all`, `AT`, `BE`, `BG`, `CH`, `CY`, `CZ`, `DE`, `DK`, `EE`, `ES`, `FI`, `FR`, `GB`, `GR`, `HR`, `HU`, `IE`, `IS`, `IT`, `LI`, `LT`, `LU`, `LV`, `MT`, `NL`, `NO`, `PL`, `PT`, `RO`, `SE`, `SI`, `SK`, `TR` | Where the ads were shown: a 2-letter country code (DE, FR, GB, …) of the 33 countries the library covers, or `all`. | `DE` |
| `cursor` | string | no |  |  | The `cursor` from the previous response, to get the next page. Keep every other param the same. |  |

## Example request

Replace `YOUR_API_KEY` with your key, or set `LURKAPI_KEY` for the code. [Get a free key](https://lurkapi.com/login?next=/dashboard).

curl:

```bash
curl "https://api.lurkapi.com/v1/tiktok/ad-library/search?query=running+shoes&region=DE" \
  -H "x-api-key: YOUR_API_KEY"
```

JavaScript:

```js
const params = new URLSearchParams({
  query: "running shoes",
  region: "DE",
});
const res = await fetch(`https://api.lurkapi.com/v1/tiktok/ad-library/search?${params}`, {
  headers: { "x-api-key": process.env.LURKAPI_KEY },
});
const data = await res.json();
if (!data.success) throw new Error(`${data.code}: ${data.error}`);
console.log(data.ads);
```

Python:

```python
import os
import requests

res = requests.get(
    "https://api.lurkapi.com/v1/tiktok/ad-library/search",
    params={
        "query": "running shoes",
        "region": "DE",
    },
    headers={"x-api-key": os.environ["LURKAPI_KEY"]},
    timeout=60,
)
data = res.json()
if not data["success"]:
    raise RuntimeError(f"{data['code']}: {data['error']}")
print(data["ads"])
```

## Example response

A real response from this endpoint, captured from the live API and trimmed to a couple of items. Strings over 96 characters (mostly signed media URLs) are cut short and end in `…`.

200 OK (application/json):

```json
{
  "success": true,
  "credits_remaining": 999988,
  "credits_charged": 1,
  "ads": [
    {
      "id": "1876549962700817",
      "url": "https://library.tiktok.com/ads/detail/?ad_id=1876549962700817",
      "advertiser_name": "扬州哲鸟网络科技有限公司",
      "title": "Breathable Running Shoes for Men",
      "category": "Apparel & Accessories",
      "first_shown": 1789603200,
      "last_shown": 1789603200,
      "estimated_audience": "0-1K",
      "videos": [
        {
          "url": "https://library.tiktok.com/api/v1/cdn/1790776192/video/aHR0cHM6Ly92MTZtL…",
          "cover": "https://p16-common-sign.tiktokcdn.com/tos-alisg-p-0051c001-sg/owrWfpAWeA…"
        }
      ],
      "image_urls": [
        "https://p16-common-sign.tiktokcdn.com/tos-alisg-p-0051c001-sg/owrWfpAWeA…"
      ]
    },
    {
      "id": "1876549961564434",
      "url": "https://library.tiktok.com/ads/detail/?ad_id=1876549961564434",
      "advertiser_name": "扬州哲鸟网络科技有限公司",
      "title": "Breathable Running Shoes for Men",
      "category": "Apparel & Accessories",
      "first_shown": 1789603200,
      "last_shown": 1789603200,
      "estimated_audience": "0-1K",
      "videos": [
        {
          "url": "https://library.tiktok.com/api/v1/cdn/1790776192/video/aHR0cHM6Ly92MTZtL…",
          "cover": "https://p16-common-sign.tiktokcdn.com/tos-alisg-p-0051c001-sg/ooNNDEglIq…"
        }
      ],
      "image_urls": [
        "https://p16-common-sign.tiktokcdn.com/tos-alisg-p-0051c001-sg/ooNNDEglIq…"
      ]
    }
  ],
  "total": 5000,
  "has_more": true,
  "cursor": "eyJsYXN0X3NvcnQiOlszNy43Njk1NywxNzg5NjAzMjAwMDAwXSwibmV4dF9jdXJzb3IiOjEyfQ=="
}
```

## Response fields

Every field of a successful response. `[]` marks a list: `a[].b` is the `b` of each item in `a`. **nullable** fields can be `null`; **optional** fields can be missing.

| Field | Type | Description |
| --- | --- | --- |
| `success` | `true` | Always true here; errors have `success: false`. |
| `credits_remaining` | `number` | Your balance after this call. On anonymous playground calls: free tries left today. |
| `credits_charged` | `number` | Credits this call cost; 0 on free endpoints. On anonymous playground calls: tries used (1). |
| `ads` | `object[]` | Ads, most relevant first. |
| `ads[].id` | `string` | Ad id. Pass it as `ad_id` to TikTok Ad Library ad for targeting and reach. |
| `ads[].url` | `string` | The ad on library.tiktok.com. |
| `ads[].advertiser_name` | `string`, nullable | The advertiser as registered with TikTok; null for the few ads published without one. |
| `ads[].title` | `string`, nullable | The ad's caption text; null if it has none. |
| `ads[].category` | `string`, nullable | TikTok's category for the ad, e.g. `Apparel & Accessories` or `Apps`; null if none. |
| `ads[].first_shown` | `number` | First day the ad was shown in the library's countries, Unix seconds (midnight UTC). |
| `ads[].last_shown` | `number` | Latest day it was shown, Unix seconds (midnight UTC). Yesterday or today for ads still running. |
| `ads[].estimated_audience` | `string`, nullable | TikTok's estimate of unique users who saw the ad at least once, as a range such as `10K-100K`; null if not given. |
| `ads[].videos` | `object[]` | The ad's videos, usually one. Empty for image ads. |
| `ads[].videos[].url` | `string` | MP4 URL. It redirects to TikTok's CDN and expires about 6 hours after we fetched the ad. |
| `ads[].videos[].cover` | `string`, nullable | Cover image URL (expires about 6 hours after we fetched the ad); null if none. |
| `ads[].image_urls` | `string[]` | The ad's images, in order. Empty for most video ads. |
| `total` | `number` | Ads matching the search in the last 30 days. Keyword searches stop counting at 5,000. |
| `has_more` | `boolean` | There are more ads after this page. |
| `cursor` | `string`, nullable | Pass as `cursor` for the next page. null on the last page. |

## Pagination

Pass the response's `cursor` back as `cursor`, with the other parameters unchanged, for the next page. It's `null` on the last page. Each page costs 1 credit.

The first five pages, in JavaScript:

```js
let cursor = null;
for (let page = 1; page <= 5; page++) {
  const params = new URLSearchParams({ query: "running shoes", region: "DE" });
  if (cursor) params.set("cursor", cursor);
  const res = await fetch(`https://api.lurkapi.com/v1/tiktok/ad-library/search?${params}`, {
    headers: { "x-api-key": process.env.LURKAPI_KEY },
  });
  const data = await res.json();
  if (!data.success) throw new Error(`${data.code}: ${data.error}`);
  console.log(data.ads);
  cursor = data.cursor;
  if (!cursor) break; // last page
}
```

## Caching and freshness

Responses are cached for up to 1 hour, so a repeat call within that window can return the same data. It still costs 1 credit.

## Errors

Errors return `{ success: false, error, code, docs }` with the HTTP status below. Validation errors, `401`/`402`/`429` rejections and `5xx` failures are free; `not_found` is charged ([how charging works](https://lurkapi.com/docs.md#credits)). [All error codes](https://lurkapi.com/docs.md#errors).

| Status | Code | Meaning |
| --- | --- | --- |
| 401 | `missing_api_key` | No API key. Send it in the `x-api-key` header. |
| 401 | `invalid_api_key` | The key is unknown or was revoked. |
| 402 | `insufficient_credits` | Not enough credits for this call. Buy a pack or wait for tomorrow's top-up. |
| 404 | `not_found` | The endpoint, or the thing you asked for (ad, post, subreddit), doesn't exist. Charged when the platform was checked. |
| 405 | `method_not_allowed` | Endpoints take GET with query params. |
| 429 | `rate_limited` | Too many calls at once. Wait for the `retry-after` seconds, then retry. |
| 500 | `internal_error` | Something broke on our side. Retry; 5xx errors are free. |
| 502 | `upstream_error` | The platform didn't give a usable answer. Retry; 5xx errors are free. |
| 503 | `upstream_busy` | All our connections to the platform are busy. Retry in a few seconds; 5xx errors are free. |
| 504 | `upstream_timeout` | The platform took over 30 seconds to answer. Retry; timeouts are free. |

## Use it in Claude

Once LurkAPI is [connected to Claude](https://lurkapi.com/docs.md#claude), this endpoint is the `tiktok_ad_library_search` tool. Ask in plain English, for example:

Ask Claude:

```text
Use LurkAPI's tiktok_ad_library_search with query "running shoes", region "DE" and summarize what you find.
```

Claude calls `tiktok_ad_library_search` with arguments like these, and each call costs 1 credit:

Tool arguments:

```json
{
  "query": "running shoes",
  "region": "DE"
}
```

Tool results skip nulls and empty lists to save tokens.

---

Previous: [Song videos](https://lurkapi.com/docs/tiktok/song-videos.md) · Next: [TikTok Ad Library ad](https://lurkapi.com/docs/tiktok/ad-library-ad.md)
