# TikTok Trending Feed (`tiktok.trending_feed`)

A fresh sample of TikTok's For You feed as served from one country, with caption, author and engagement per video.

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

- Endpoint: `POST https://api.primaryapi.com/v1/run/tiktok.trending_feed`
- Category: Social · Platform: `tiktok` · Kind: list · Status: live
- Price: 3 credits per call. Every call costs the same, including calls that were retried automatically.
- 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.trending_feed`
- Execution: synchronous (answers 202 only if it outlives the wait window)

## Input

| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
| `region` | string | yes |  | pattern: ^[A-Za-z]{2}$ | Two-letter country code the feed is requested from, e.g. "US" (content not banned there; not a ranking by country). |
| `trim` | boolean \| enum | no |  |  | AnyAPI-compatible flag; accepted and ignored — responses always use the normalised shape. |
| `limit` | integer | no | 20 | 1–50 | Maximum number of results to return (1-50, 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 |
|---|---|---|
| `videos` | object[] |  |
| `videos[].id` | string | TikTok video id (aweme_id) |
| `videos[].url` | string \| null | Canonical web URL of the post |
| `videos[].caption` | string \| null | Post text including hashtags |
| `videos[].createdUtc` | string \| null | ISO-8601 UTC creation time |
| `videos[].durationSeconds` | number \| null | Video length in seconds |
| `videos[].hashtags` | string[] | Hashtags without # |
| `videos[].image` | string \| null | Cover/thumbnail URL (signed, expires) |
| `videos[].likes` | integer \| null |  |
| `videos[].comments` | integer \| null |  |
| `videos[].shares` | integer \| null |  |
| `videos[].saves` | integer \| null | Bookmark/collect count |
| `videos[].views` | integer \| null | Play count |
| `videos[].authorHandle` | string \| null | Creator @handle without @ |
| `videos[].authorName` | string \| null |  |
| `videos[].authorUserId` | string \| null |  |
| `videos[].authorImage` | string \| null |  |
| `videos[].authorVerified` | boolean \| null |  |
| `videos[].authorFollowers` | integer \| null | Creator follower count when the source provides it |
| `videos[].soundTitle` | string \| null |  |
| `videos[].soundAuthor` | string \| null |  |
| `videos[].soundClipId` | string \| null |  |
| `videos[].videoUrl` | string \| null | Playable MP4 URL (signed, expires; may be IP-bound) |
| `videos[].sdVideoUrl` | string \| null | Lower-bitrate MP4 URL when the source lists several renditions |
| `videos[].region` | string \| null | Region code of the post when provided |
| `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.trending_feed" \
  -H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"region":"US"}'
```

## 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": {
      "videos": [
        {
          "id": "string",
          "url": "https://example.com",
          "caption": "string",
          "createdUtc": "string",
          "durationSeconds": 0,
          "hashtags": [
            "string"
          ],
          "image": "string",
          "likes": 0,
          "comments": 0,
          "shares": 0,
          "saves": 0,
          "views": 0,
          "authorHandle": "string",
          "authorName": "string",
          "authorUserId": "string",
          "authorImage": "string",
          "authorVerified": true,
          "authorFollowers": 0,
          "soundTitle": "string",
          "soundAuthor": "string",
          "soundClipId": "string",
          "videoUrl": "https://example.com",
          "sdVideoUrl": "https://example.com",
          "region": "US"
        }
      ],
      "nextCursor": null
    }
  },
  "provider": "PrimaryAPI",
  "credits": 3,
  "items": 1,
  "requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z",
  "nextCursor": null
}
```

## Pricing and reliability

- Usual price: 3 credits per call
- Price ceiling: the usual price, even when a call is retried. 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.trending_feed`

## 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

A rotating sample, not a ranked chart: every call returns a different batch (no pagination; do not cache). Feed items omit the creator handle on some posts (taken from the post URL) and carry no follower or sound fields.

