> 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 Ads Top

Structured TikTok data: every input is optional. Cursor-paginated, 1 credit per successful call.

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

## Overview

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

## Request

```bash
curl -G "https://api.scrapier.io/api/v2/tiktok-ads-top/" \
  -H "X-API-Key: YOUR_API_KEY" \
  --max-time 210
```

```python
import requests

resp = requests.get(
    "https://api.scrapier.io/api/v2/tiktok-ads-top/",
    headers={"X-API-Key": "YOUR_API_KEY"},
    params={},
    timeout=210,
)
body = resp.json()
if not resp.ok:
    raise RuntimeError(body.get("error") or body.get("detail"))

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

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

## Parameters

> **Note:** No parameter is strictly required, but send at least the inputs shown in the example.

| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `X-API-Key` (header) | string | yes | — | Your API key. |
| `keyword` | string | no | — | Optional search term (login-gated by TikTok: echoed, not applied). Each call returns one leaderboard partition (<=20 ads); pass next_cursor to walk deeper into the same filter combination. |
| `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. |
| `country` | string | no | `US` | ISO-2 country code, validated live against TikTok's top_ads country list. |
| `period` | integer | no | `180` | Leaderboard lookback window in days. One of: `7`, `30`, `180`. |
| `order_by` | string | no | `for_you` | Leaderboard ranking axis. One of: `for_you`, `impression`, `ctr`, `play_2s_rate`, `play_6s_rate`, `cvr`, `like`. |
| `ad_format` | string | no | `All ad types` | Ad format filter. One of: `All ad types`, `Spark ads`, `Non-Spark ads`. |
| `ad_language` | string | no | `en` | Ad language code. |
| `like_tier` | integer | no | — | Engagement-tier bucket (1 = top tier). |
| `industry` | string | no | `Skincare` | Industry label, matched live. |
| `max_items` | integer | no | `20` | Ads per page (values >20 clamp to 20 = one TikTok leaderboard partition). Follow next_cursor for more; the pool is a few hundred ads for broad filters. |
| `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.items`. Sample from the live catalog, arrays trimmed to 3 items.

```json
{
  "success": true,
  "data": {
    "keyword": null,
    "country": "US",
    "period": 180,
    "order_by": "for_you",
    "ad_format": 0,
    "ad_language": "en",
    "like_tier": null,
    "industry": "Skincare",
    "success": true,
    "error": null,
    "warnings": [],
    "warning": null,
    "items": [
      {
        "post": {
          "id": "7160811838573182977",
          "url": "https://ads.tiktok.com/business/creativecenter/topads/7160811838573182977/pc/en?countryCode=US&period=180",
          "content": {
            "text": "You take pride in your work. But let's face it - using subpar wax can ruin even the best intentions.",
            "media_urls": "https://v16m-default.tiktokcdn.com/.../video/tos/alisg/tos-alisg-ve-0051c001-sg/....mp4",
            "thumbnail_url": "https://p16-common-sign.tiktokcdn.com/....image",
            "duration_seconds": 51.2
          },
          "author": {
            "username": "honeycombwaxco",
            "display_name": "honeycombwaxco",
            "avatar_url": null,
            "verified": false
          },
          "engagement": {
            "views": null,
            "likes": 19757,
            "comments": 125,
            "shares": 82,
            "saves": null
          },
          "flags": {
            "nsfw": null,
            "spoiler": null,
            "pinned": null,
            "deleted": false
          },
          "published_at": null,
          "ext": {
            "ad": {
              "ctr": 0.07,
              "rank": 1,
              "cost_score": 2,
              "like_tier": null,
              "industry": "Skincare",
              "objective": "campaign_objective_conversion",
              "is_spark_ad": null,
              "ad_format": null,
              "language": "en",
              "country_code": "US",
              "period_days": 180,
              "video_id": "v10033g50000cdg4vn3c77u4nq4b21ig",
              "video_url_540p": null,
              "video_url_360p": null,
              "landing_page_url": null,
              "order_by": "for_you",
              "detail_fetched": true
            }
          }
        },
        "computed": {
          "engagement_rate": null,
          "language": "en",
          "content_category": "beauty",
          "estimated_reach": null
        }
      }
    ],
    "returned_count": 3,
    "total_count": 381,
    "dropped": 0,
    "detail_missing": 0,
    "has_more": true,
    "scraped_at": "2026-09-23T09:30:00.000Z",
    "next_cursor": "eyJiIjoi...base64 Bloom filter + locked filters + slot index (~1.2KB)...In0"
  }
}
```

## Response fields

| Field | Type | Example | Description |
|---|---|---|---|
| `keyword` | null | `null` |  |
| `country` | string | `US` |  |
| `period` | integer | `180` |  |
| `order_by` | string | `for_you` |  |
| `ad_format` | integer | `0` |  |
| `ad_language` | string | `en` |  |
| `like_tier` | null | `null` |  |
| `industry` | string | `Skincare` |  |
| `success` | boolean | `true` |  |
| `error` | null | `null` |  |
| `warnings` | array | `[]` |  |
| `warning` | null | `null` |  |
| `items` | array | `[1 item]` | The results. |
| `returned_count` | integer | `3` |  |
| `total_count` | integer | `381` |  |
| `dropped` | integer | `0` |  |
| `detail_missing` | integer | `0` |  |
| `has_more` | boolean | `true` |  |
| `scraped_at` | string | `2026-09-23T09:30:00.000Z` |  |
| `next_cursor` | string | `eyJiIjoi...base64 Bloom filter + locked filte…` | Pass back as `cursor` for the next page. `null` on the last page. |
| `items[].post` | object | `{…}` |  |
| `items[].computed` | object | `{…}` |  |

## 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-top/"
HEADERS = {"X-API-Key": "YOUR_API_KEY"}
params = {}
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("items") 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

- The response data carries its own `success` field from the scraper. The outer `success` is what counts: an HTTP 200 with outer `success: true` is billed, even if the inner field says otherwise.

## 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 Ad Library](https://docs.scrapier.io/api-reference/tiktok/tiktok-ads.md): Structured TikTok data: send `urls`. 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.
