# TikTok Video Download (`tiktok.video_download`)

Direct media links for a public TikTok video: the no-watermark MP4, the watermarked MP4 and the cover, with size and duration.

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

- Endpoint: `POST https://api.primaryapi.com/v1/run/tiktok.video_download`
- Category: Social · Platform: `tiktok` · Kind: lookup · Status: live
- Price: 1 credit per call; up to 3 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.video_download`
- Execution: synchronous (answers 202 only if it outlives the wait window)

## Input

| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
| `url` | string | yes |  | max 2048 chars; format: uri | TikTok post URL on tiktok.com: a video or photo post (https://www.tiktok.com/@<user>/video/<id> or /photo/<id>) or a vm.tiktok.com / vt.tiktok.com share link. Share links and tracking query params are fine. |

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 |
|---|---|---|
| `id` | string | TikTok video id (aweme_id) |
| `url` | string \| null | Canonical web URL of the post |
| `videoUrl` | string \| null | No-watermark MP4 URL (signed, expires; may be IP-bound). null when TikTok returned none |
| `watermarkedUrl` | string \| null | Watermarked MP4 (what TikTok's own save button produces) |
| `sdVideoUrl` | string \| null | Playback MP4 URL (play_addr); not necessarily lower quality |
| `width` | integer \| null | Pixels |
| `height` | integer \| null | Pixels |
| `durationSeconds` | number \| null |  |
| `image` | string \| null | Cover image URL |
| `caption` | string \| null |  |
| `hashtags` | string[] |  |
| `createdUtc` | string \| null |  |
| `region` | string \| null |  |
| `authorHandle` | string \| null |  |
| `authorName` | string \| null |  |
| `authorUserId` | string \| null |  |
| `authorImage` | string \| null |  |
| `authorVerified` | boolean \| null |  |
| `authorFollowers` | integer \| null |  |
| `soundTitle` | string \| null |  |
| `soundAuthor` | string \| null |  |
| `soundClipId` | string \| 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.video_download" \
  -H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://www.tiktok.com/@scout2015/video/6718335390845095173"}'
```

## 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": {
      "id": "string",
      "url": "https://www.tiktok.com/@scout2015/video/6718335390845095173",
      "videoUrl": "https://example.com",
      "watermarkedUrl": "https://example.com",
      "sdVideoUrl": "https://example.com",
      "width": 0,
      "height": 0,
      "durationSeconds": 0,
      "image": "string",
      "caption": "string",
      "hashtags": [
        "string"
      ],
      "createdUtc": "string",
      "region": "string",
      "authorHandle": "string",
      "authorName": "string",
      "authorUserId": "string",
      "authorImage": "string",
      "authorVerified": true,
      "authorFollowers": 0,
      "soundTitle": "string",
      "soundAuthor": "string",
      "soundClipId": "string"
    }
  },
  "provider": "PrimaryAPI",
  "credits": 1,
  "items": 1,
  "requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z"
}
```

## Pricing and reliability

- Usual price: 1 credit per call
- Price ceiling: up to 3 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.video_download`

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

Returns URLs only — media is never stored or proxied (creator copyright). CDN links are signed, expire within hours and may be IP-bound, so download promptly from the same network. Photo-mode posts carry no video file (reason not_a_video; use tiktok.photos).

