> 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 Trending Videos

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

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

## Overview

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

## Request

```bash
curl -G "https://api.scrapier.io/api/v2/tiktok-trending-videos/" \
  -H "X-API-Key: YOUR_API_KEY" \
  --data-urlencode "country_code=US" \
  --max-time 210
```

```python
import requests

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

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

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. |
| `country_code` | string | yes | e.g. `US` | Country: US, JP, VN, TH or ID (the countries TikTok Creative Center ranks videos for). Required on first call; ignored when `cursor` is supplied. One of: `US`, `JP`, `VN`, `TH`, `ID`. |
| `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. |
| `sort_by` | string | no | `hot` | Ranking metric: hot/views (video views), engagement (alias like/share/comment), six_second_views. Locked into the cursor. One of: `hot`, `views`, `engagement`, `six_second_views`, `view`, `like`, `share`, `comment`. |
| `period` | string | no | `7` | 7 (videos created in last 7 days), 30 (last 30 days), weekly, monthly. Deeper pages walk older ranking windows. Locked into the cursor. One of: `7`, `30`, `weekly`, `monthly`. |
| `content_tag` | string | no | — | Optional content filter (comma-separated): beauty, fashion, food, lifestyle, tech. Empty = all. Locked into the cursor. |
| `organic_only` | boolean | no | `false` | Only organic (non-promoted) videos. Locked into the cursor. |
| `page_size` | integer | no | `25` | Videos per page (1-100). Locked into the cursor. |
| `include_details` | boolean | no | `false` | true = add tiktok.com stats (likes, shares, comments, saves, plays, duration) per video, fetched in parallel within the call ~24 s budget; a video whose stats miss the budget is still returned with stats null and stats_pending=true (Creative Center views/engagement always present). false = listing only (~3-5 s). 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.videos`. Sample from the live catalog, arrays trimmed to 3 items.

```json
{
  "success": true,
  "data": {
    "country_code": "US",
    "period": "7",
    "sort_by": "views",
    "page": 1,
    "page_size": 25,
    "videos": [
      {
        "country_code": "US",
        "cover": "https://p16-common-sign.tiktokcdn-us.com/tos-useast5-p-0068-tx/o81vAiZAY0BgmWspOa5ZIkVEAiWDCTBErj4A2~tplv-tiktokx-origin.image",
        "duration": 66,
        "id": "7680342145466780941",
        "item_id": "7680342145466780941",
        "item_url": "https://www.tiktok.com/@renz.sadiwa/video/7680342145466780941",
        "region": "United States",
        "title": "3 NEW Gemini Live Features That Should Not Be This Good",
        "diggCount": 23700,
        "shareCount": 844,
        "commentCount": 212,
        "playCount": 66100000,
        "collectCount": 3356,
        "videoUrl": "https://v16-webapp-prime.tiktok.com/video/tos/alisg/...",
        "video_id": "7680342145466780941",
        "url": "https://www.tiktok.com/@renz.sadiwa/video/7680342145466780941",
        "description": "3 NEW Gemini Live Features That Should Not Be This Good",
        "author_username": "renz.sadiwa",
        "author_nickname": "Renz Sadiwa",
        "author_id": "6757836093687514118",
        "author_followers": 208907,
        "author_avatar": "https://p16-common-sign.tiktokcdn-us.com/tos-useast5-avt-0068-tx/fd28960c3222a012607ffe91574d4134~tplv-tiktokx-cropcenter:300:300.jpeg",
        "author_bio": "Tech | Lifestyle",
        "create_time": "2026-08-31T23:30:28Z",
        "play_count": 66100000,
        "like_count": 23700,
        "video_views": 39218761,
        "video_views_lifetime": 52968271,
        "organic_video_views": 489679,
        "organic_video_views_lifetime": 1166715,
        "engagement_rate": 0.000392,
        "engagement_rate_lifetime": 0.000382,
        "six_seconds_vtr": 0.012569,
        "six_seconds_vtr_lifetime": 0.012242,
        "cover_avif": "https://p16-common-sign.tiktokcdn-us.com/tos-useast5-p-0068-tx/o81vAiZAY0BgmWspOa5ZIkVEAiWDCTBErj4A2~tplv-photomode-zoomcover-tcm:720:720.avif",
        "rank": 1,
        "period": "7",
        "sort_by": "views",
        "content_tag": "all",
        "organic_only": false,
        "ranking_window_end": "2026-09-28T00:00:00Z",
        "ranking_window_index": 0,
        "scraped_at": "2026-10-01T12:00:00.000Z",
        "input_country": "US",
        "stats_pending": false
      }
    ],
    "next_cursor": "tv1.eNpVjk0KgzAQhe8y6yzM1L8DdNdlj1B0YhtQoyamFfHuJlHaLoZh3ve-YZ5QaYdQFKUWbbOlhh8CLeEBwj2nr3G7kTAJcE5TZOlo5dPxH0pNFE0mnA8MiPAy4j0SwMn9VQ5mlkDq3Zx0zLVz52Y8WjiUL"
  }
}
```

## Response fields

| Field | Type | Example | Description |
|---|---|---|---|
| `country_code` | string | `US` |  |
| `period` | string | `7` |  |
| `sort_by` | string | `views` |  |
| `page` | integer | `1` |  |
| `page_size` | integer | `25` |  |
| `videos` | array | `[1 item]` | The results. |
| `next_cursor` | string | `tv1.eNpVjk0KgzAQhe8y6yzM1L8DdNdlj1B0YhtQoyamF…` | Pass back as `cursor` for the next page. `null` on the last page. |
| `videos[].country_code` | string | `US` |  |
| `videos[].cover` | string | `https://p16-common-sign.tiktokcdn-us.com/tos-…` |  |
| `videos[].duration` | integer | `66` |  |
| `videos[].id` | string | `7680342145466780941` |  |
| `videos[].item_id` | string | `7680342145466780941` |  |
| `videos[].item_url` | string | `https://www.tiktok.com/@renz.sadiwa/video/768…` |  |
| `videos[].region` | string | `United States` |  |
| `videos[].title` | string | `3 NEW Gemini Live Features That Should Not Be…` |  |
| `videos[].diggCount` | integer | `23700` |  |
| `videos[].shareCount` | integer | `844` |  |
| `videos[].commentCount` | integer | `212` |  |
| `videos[].playCount` | integer | `66100000` |  |
| `videos[].collectCount` | integer | `3356` |  |
| `videos[].videoUrl` | string | `https://v16-webapp-prime.tiktok.com/video/tos…` |  |
| `videos[].video_id` | string | `7680342145466780941` |  |
| `videos[].url` | string | `https://www.tiktok.com/@renz.sadiwa/video/768…` |  |
| `videos[].description` | string | `3 NEW Gemini Live Features That Should Not Be…` |  |
| `videos[].author_username` | string | `renz.sadiwa` |  |
| `videos[].author_nickname` | string | `Renz Sadiwa` |  |
| `videos[].author_id` | string | `6757836093687514118` |  |
| `videos[].author_followers` | integer | `208907` |  |
| `videos[].author_avatar` | string | `https://p16-common-sign.tiktokcdn-us.com/tos-…` |  |
| `videos[].author_bio` | string | `Tech \| Lifestyle` |  |
| `videos[].create_time` | string | `2026-08-31T23:30:28Z` |  |
| `videos[].play_count` | integer | `66100000` |  |
| `videos[].like_count` | integer | `23700` |  |
| `videos[].video_views` | integer | `39218761` |  |
| `videos[].video_views_lifetime` | integer | `52968271` |  |
| `videos[].organic_video_views` | integer | `489679` |  |
| `videos[].organic_video_views_lifetime` | integer | `1166715` |  |
| `videos[].engagement_rate` | number | `0.000392` |  |
| `videos[].engagement_rate_lifetime` | number | `0.000382` |  |
| `videos[].six_seconds_vtr` | number | `0.012569` |  |
| `videos[].six_seconds_vtr_lifetime` | number | `0.012242` |  |
| `videos[].cover_avif` | string | `https://p16-common-sign.tiktokcdn-us.com/tos-…` |  |
| `videos[].rank` | integer | `1` |  |
| `videos[].period` | string | `7` |  |
| `videos[].sort_by` | string | `views` |  |
| `videos[].content_tag` | string | `all` |  |
| `videos[].organic_only` | boolean | `false` |  |
| `videos[].ranking_window_end` | string | `2026-09-28T00:00:00Z` |  |
| `videos[].ranking_window_index` | integer | `0` |  |
| `videos[].scraped_at` | string | `2026-10-01T12:00:00.000Z` |  |
| `videos[].input_country` | string | `US` |  |
| `videos[].stats_pending` | boolean | `false` |  |

## 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-trending-videos/"
HEADERS = {"X-API-Key": "YOUR_API_KEY"}
params = {"country_code": "US"}
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("videos") 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 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 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.
