> Documentation index: https://docs.scrapier.io/llms.txt
> Auth: header `X-API-Key: <key>` · Base: https://api.scrapier.io/api/v2 · Synchronous; paginate with `cursor` ← `data.next_cursor`.

# TikTok Ad Library

Structured TikTok data: send `urls`. Cursor-paginated, 1 credit per successful call.

`GET|POST https://api.scrapier.io/api/v2/tiktok-ads/` · 1 credit per successful call · Cursor-paginated

## Overview

Call `GET /api/v2/tiktok-ads/` with `urls`. The results are in `data.ads`; send `data.next_cursor` back as `cursor` to get the next page. 2 optional parameters refine the call (see Parameters).

## Request

```bash
curl -G "https://api.scrapier.io/api/v2/tiktok-ads/" \
  -H "X-API-Key: YOUR_API_KEY" \
  --data-urlencode "urls=https://library.tiktok.com/ads?region=all&adv_name=NVIDIA%20GmbH&adv_biz_ids=6891503886842987266&query_type=2&sort_type=last_shown_date,desc" \
  --max-time 210
```

```python
import requests

resp = requests.get(
    "https://api.scrapier.io/api/v2/tiktok-ads/",
    headers={"X-API-Key": "YOUR_API_KEY"},
    params={"urls": "https://library.tiktok.com/ads?region=all&adv_name=NVIDIA%20GmbH&adv_biz_ids=6891503886842987266&query_type=2&sort_type=last_shown_date,desc"},
    timeout=210,
)
body = resp.json()
if not resp.ok:
    raise RuntimeError(body.get("error") or body.get("detail"))

print(body["data"]["ads"])
```

POST with a JSON body works too (same parameters; the body is merged over the query string).

## Parameters

| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `X-API-Key` (header) | string | yes | — | Your API key. |
| `urls` | string | yes | e.g. `https://library.tiktok.com/ads?region=all&adv_name=NVIDIA%20GmbH&adv_biz_ids=6891503886842987266&query_type=2&sort_type=last_shown_date,desc` | TikTok Ad Library search URL (filters: region, start_time/end_time, adv_name, adv_biz_ids, query_type, sort_type, ad_type, ad_status, ages, ad_reach, gender) or a bare keyword. One page = 12 ads (TikTok's fixed page size). Required on first call; ignored when `cursor` is supplied (filters are locked into it). |
| `cursor` | string | no | — | Pagination cursor returned in the previous response's `next_cursor`. Pass it back unchanged to fetch the next page. When `next_cursor` is null, you have reached the last page. |
| `include_details` | boolean | no | `true` | Fetch each ad's detail record (paid-by, per-region impressions, targeting). Best-effort: if TikTok rate-limits it, ads come from search-card data (detail_fetched=false) with a `warning`. Locked into the cursor. |
| `use_proxy` | boolean | no | `true` | Route the request through Scrapier's residential proxy pool. Default: `true`. Leave as is unless support tells you otherwise. |
| `raw_data` | boolean | no | `false` | When true, the response carries the full raw upstream payload(s) the scraper received (GraphQL / JSON API bodies, HTML, embedded JSON-LD -- exactly as the platform returned them) under `raw_responses`, in place of the formatted items. When false (default) you get the formatted output. Pagination (`cursor` / `next_cursor`) works the same in both modes. |

## Response

HTTP 200. Results are in `data.ads`. Sample from the live catalog, arrays trimmed to 3 items.

```json
{
  "success": true,
  "data": {
    "urls": "https://library.tiktok.com/ads?region=all&adv_name=NVIDIA%20GmbH&query_type=2",
    "page": 1,
    "page_size": 12,
    "total": 311,
    "ads": [
      {
        "adId": "1874157948935201",
        "adName": "Discover the new GeForce RTX",
        "advertiserName": "NVIDIA GmbH",
        "impressions": {
          "lowerBound": 10000,
          "upperBound": 100000
        },
        "paidBy": "NVIDIA GmbH",
        "regionStats": [
          {
            "regionCode": "DE",
            "impressions": 100000
          }
        ],
        "startUrl": "https://library.tiktok.com/ads?region=all&start_time=1786665600000&end_time=1786665600000&adv_name=NVIDIA%20GmbH&adv_biz_ids=6891503886842987266&query_type=2&sort_type=last_shown_date%2Cdesc",
        "videos": [
          {
            "url": "https://library.tiktok.com/api/v1/cdn/.../video/...",
            "coverImageUrl": "https://p16-common-sign.tiktokcdn.com/...jpeg"
          }
        ],
        "ad_id": "1874157948935201",
        "ad_title": "Discover the new GeForce RTX",
        "advertiser_name": "NVIDIA GmbH",
        "advertiser_id": "6891503886842987266",
        "first_shown_date": "2026-08-01",
        "last_shown_date": "2026-08-11",
        "region": "DE",
        "url": "https://library.tiktok.com/ads/detail/?ad_id=1874157948935201",
        "estimated_audience": "10K-100K",
        "image_urls": [
          "https://p16-common-sign.tiktokcdn.com/...jpeg"
        ],
        "external_url": "https://www.nvidia.com/de-de/geforce/",
        "subject": "Electronics",
        "advertiser_registry_location": "Germany",
        "advertiser_tiktok_username": "nvidiageforce_de",
        "advertiser_tiktok_followers": "120.5K",
        "target_audience_size": "7.1M-8.7M",
        "targeting_age": [
          {
            "region": "DE",
            "13-17": false,
            "18-24": true,
            "25-34": true,
            "35-44": true,
            "45-54": false,
            "55+": false
          }
        ],
        "targeting_gender": [
          {
            "region": "DE",
            "female": true,
            "male": true,
            "unknown": true
          }
        ],
        "detail_fetched": true,
        "input_url": "https://library.tiktok.com/ads?region=all&adv_name=NVIDIA%20GmbH&query_type=2",
        "scraped_at": "2026-12-01T12:00:00.000Z"
      }
    ],
    "has_more": true,
    "next_cursor": "ta1.eNqrVirLz0lVslIqzs_NTVWyUqrLLy0pVbJSMjQ3NjdQ0lEqSsxLSc3PU7JSMjE0MDBQ0lEqLE..."
  }
}
```

## Response fields

| Field | Type | Example | Description |
|---|---|---|---|
| `urls` | string | `https://library.tiktok.com/ads?region=all&adv…` |  |
| `page` | integer | `1` |  |
| `page_size` | integer | `12` |  |
| `total` | integer | `311` |  |
| `ads` | array | `[1 item]` | The results. |
| `has_more` | boolean | `true` |  |
| `next_cursor` | string | `ta1.eNqrVirLz0lVslIqzs_NTVWyUqrLLy0pVbJSMjQ3N…` | Pass back as `cursor` for the next page. `null` on the last page. |
| `ads[].adId` | string | `1874157948935201` |  |
| `ads[].adName` | string | `Discover the new GeForce RTX` |  |
| `ads[].advertiserName` | string | `NVIDIA GmbH` |  |
| `ads[].impressions` | object | `{…}` |  |
| `ads[].paidBy` | string | `NVIDIA GmbH` |  |
| `ads[].regionStats` | array | `[1 item]` |  |
| `ads[].startUrl` | string | `https://library.tiktok.com/ads?region=all&sta…` |  |
| `ads[].videos` | array | `[1 item]` |  |
| `ads[].ad_id` | string | `1874157948935201` |  |
| `ads[].ad_title` | string | `Discover the new GeForce RTX` |  |
| `ads[].advertiser_name` | string | `NVIDIA GmbH` |  |
| `ads[].advertiser_id` | string | `6891503886842987266` |  |
| `ads[].first_shown_date` | string | `2026-08-01` |  |
| `ads[].last_shown_date` | string | `2026-08-11` |  |
| `ads[].region` | string | `DE` |  |
| `ads[].url` | string | `https://library.tiktok.com/ads/detail/?ad_id=…` |  |
| `ads[].estimated_audience` | string | `10K-100K` |  |
| `ads[].image_urls` | array | `[1 item]` |  |
| `ads[].external_url` | string | `https://www.nvidia.com/de-de/geforce/` |  |
| `ads[].subject` | string | `Electronics` |  |
| `ads[].advertiser_registry_location` | string | `Germany` |  |
| `ads[].advertiser_tiktok_username` | string | `nvidiageforce_de` |  |
| `ads[].advertiser_tiktok_followers` | string | `120.5K` |  |
| `ads[].target_audience_size` | string | `7.1M-8.7M` |  |
| `ads[].targeting_age` | array | `[1 item]` |  |
| `ads[].targeting_gender` | array | `[1 item]` |  |
| `ads[].detail_fetched` | boolean | `true` |  |
| `ads[].input_url` | string | `https://library.tiktok.com/ads?region=all&adv…` |  |
| `ads[].scraped_at` | string | `2026-12-01T12:00:00.000Z` |  |

## Pagination

Pass `data.next_cursor` back as `cursor` until it is `null`. Required inputs are ignored once a cursor is sent. Each page is one billed call.

```python
import requests

URL = "https://api.scrapier.io/api/v2/tiktok-ads/"
HEADERS = {"X-API-Key": "YOUR_API_KEY"}
params = {"urls": "https://library.tiktok.com/ads?region=all&adv_name=NVIDIA%20GmbH&adv_biz_ids=6891503886842987266&query_type=2&sort_type=last_shown_date,desc"}
items = []

for _ in range(10):  # each page is one billed call
    resp = requests.get(URL, headers=HEADERS, params=params, timeout=210)
    resp.raise_for_status()
    data = resp.json()["data"]
    items.extend(data.get("ads") or [])
    if not data.get("next_cursor"):  # None = last page
        break
    params = {"cursor": data["next_cursor"]}
```

## Errors

Failed calls are free. Branch on HTTP status; the message is in `error` (or `detail`). See https://docs.scrapier.io/errors.md

- **400** Bad input. The exact message varies by endpoint. `{"success":false,"error":"…"}`
- **402** Balance below the endpoint's price. `{"error":"Insufficient credits. Buy more to scrape more.","balance":1,"required":2}`
- **403** Invalid or unknown API key. `{"detail":"Authentication service unavailable or invalid API key."}`
- **429** Throttled — wait for Retry-After. `{"detail":"Request was throttled. Expected available in N seconds."}`
- **404** unknown slug · **503** busy (retry after `Retry-After`) · **5xx** upstream failure or timeout (retry with backoff).

## Notes

- Nothing special: send the inputs, read the result.

## Related

- [TikTok Ad Library Leads](https://docs.scrapier.io/api-reference/tiktok/tiktok-ad-library-leads.md): Structured TikTok data: every input is optional. Single lookup, 3 credits per successful call.
- [TikTok Ads Top](https://docs.scrapier.io/api-reference/tiktok/tiktok-ads-top.md): Structured TikTok data: every input is optional. Cursor-paginated, 1 credit per successful call.
- [TikTok Collection Videos](https://docs.scrapier.io/api-reference/tiktok/tiktok-collection-videos.md): Structured TikTok data: send `urls`. Cursor-paginated, 1 credit per successful call.
- [TikTok Comment Replies](https://docs.scrapier.io/api-reference/tiktok/tiktok-comment-replies.md): Structured TikTok data: send `urls`. Cursor-paginated, 1 credit per successful call.
