# TikTok Top Ads Search (`tiktok.top_ads_search`)

Search TikTok Creative Center top-performing video ads by brand or product keyword, with objective, period and performance filters.

Docs: https://primaryapi.com/docs/api-reference/tiktok/top_ads_search

- Endpoint: `POST https://api.primaryapi.com/v1/run/tiktok.top_ads_search`
- Category: Web Intelligence · Platform: `tiktok` · Kind: search · Status: live
- Price: 2 credits per call; up to 52 credits if a call is retried elsewhere. A quote’s `maxCredits` is the most a given call can cost.
- Billing unit: per successful call
- Reliability: routed to a healthy upstream and retried automatically when an attempt fails; live 30-day status: `GET https://api.primaryapi.com/v1/status/apis?sku=tiktok.top_ads_search`
- Execution: synchronous (answers 202 only if it outlives the wait window)

## Input

| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
| `query` | string | yes |  | max 500 chars | Brand or product keyword to search in Creative Center top ads, e.g. "nike". |
| `objective` | enum | no |  | one of: traffic, app_installs, conversions, video_views, reach, lead_generation, product_sales | Campaign objective filter. Omit to search every objective. |
| `performanceRank` | enum | no |  | one of: top_1_20, top_21_40, top_41_60, top_61_80 | Likes percentile bucket: top_1_20 is the best-performing 20 percent. Omit to search every bucket. |
| `period` | 7 \| 30 \| 180 | no | 180 |  | Lookback period in days: 7, 30 or 180 (default 180). |
| `page` | integer | no | 1 | 1–50 | One-based page number (default 1). |
| `limit` | integer | no | 20 | 1–20 | Maximum number of results to return (1-20, default 20). |

Unknown fields are rejected with `400 invalid_input`. The routing controls `preferLatencyUnderMs` and `maxCredits` may be sent in the same JSON body.

## Output

When `output.found` is `true`, `output.data` has this shape:

| Field | Type | Description |
|---|---|---|
| `ads` | object[] |  |
| `ads[].adId` | string |  |
| `ads[].adTitle` | string \| null |  |
| `ads[].brandName` | string \| null |  |
| `ads[].industry` | string \| null | Creative Center industry id (e.g. "15100000000") |
| `ads[].objective` | string \| null | Campaign objective key without the "campaign_objective_" prefix |
| `ads[].cost` | integer \| null | Creative Center cost bucket (1 = low … 3 = high) |
| `ads[].ctr` | number \| null | Click-through rate as reported by Creative Center |
| `ads[].likes` | integer \| null |  |
| `ads[].durationSeconds` | number \| null |  |
| `ads[].videoUrl` | string \| null | 720p ad video URL (signed, expires) |
| `ads[].image` | string \| null | Cover image URL |
| `ads[].width` | integer \| null |  |
| `ads[].height` | integer \| null |  |
| `ads[].landingPage` | string \| null |  |
| `total` | integer \| null | Total matching ads when the source reports it |
| `hasMore` | boolean \| null |  |
| `page` | integer |  |
| `pageSize` | integer |  |
| `nextCursor` | null |  |

When the thing you asked about does not exist (or a search matches nothing) the call still succeeds: `output.found` is `false`, `output.data` is `null` and `output.reason` says why (`not_found`, `private`, `no_results`, …). Misses are free unless the notes below say misses are billed.

## Example request

```bash
curl -sS -X POST "https://api.primaryapi.com/v1/run/tiktok.top_ads_search" \
  -H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"nike"}'
```

## Example response

_Values are placeholders that follow the output schema; `credits` is what this call would cost at the usual price._

```json
{
  "output": {
    "found": true,
    "data": {
      "ads": [
        {
          "adId": "string",
          "adTitle": "string",
          "brandName": "string",
          "industry": "string",
          "objective": "string",
          "cost": 0,
          "ctr": 0,
          "likes": 0,
          "durationSeconds": 0,
          "videoUrl": "https://example.com",
          "image": "string",
          "width": 0,
          "height": 0,
          "landingPage": "string"
        }
      ],
      "total": 0,
      "hasMore": true,
      "page": 0,
      "pageSize": 0,
      "nextCursor": null
    }
  },
  "provider": "PrimaryAPI",
  "credits": 2,
  "items": 1,
  "requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z",
  "nextCursor": null
}
```

## Pricing and reliability

- Usual price: 2 credits per call
- Price ceiling: up to 52 credits if a call is retried elsewhere. A quote’s `maxCredits` is the most a given call can cost; the `maxCredits` routing control caps it per call
- Live 30-day status, success rate, uptime and latency: `GET https://api.primaryapi.com/v1/status/apis?sku=tiktok.top_ads_search`

## Errors to handle

`invalid_input`, `unauthorized`, `insufficient_balance`, `key_limit_reached`, `trial_cap_reached`, `forbidden`, `not_found`, `idempotency_conflict`, `rate_limited`, `all_sources_failed`, `service_unavailable`, `timeout`. See https://primaryapi.com/docs/errors.

## Notes

Paginate with `page` (+ hasMore).

