# tikdataapi.com

> Read-only HTTP API for public TikTok data: profiles, videos, the videos of an account, comments, replies, hashtags, video and account search, follower and following lists, sounds (music) and their videos, reposts, playlists, related videos, the trending (explore) feed, sound, live and hashtag search, the live state of an account (live now or not), and video transcripts (subtitles).
> One credit is one profile, video, comment, reply, hashtag, sound, playlist, live room or transcript returned. Empty results and failed requests cost nothing.
> Search is the general video search, the account search, the sound search and the live search of TikTok. Hashtag search is ours: TikTok gives a logged-out visitor none, so it ranks the hashtags of about 24 videos of the general search, and its counts (result_videos, result_plays) are of those videos, not the totals of TikTok (read /v1/hashtags/{name} for those). Only what TikTok shows a logged-out visitor is read: no filters of the Videos tab (ignored logged out) and no liked videos. A live room is data with no stream URL, and there are no video files.
> Credits are bought once and never expire. Base URL: https://api.tikdataapi.com. Auth: header x-api-key.

Give an agent everything in one line: MCP server at https://api.tikdataapi.com/mcp (Streamable HTTP, OAuth or header x-api-key).
Machine-readable contract: https://api.tikdataapi.com/openapi.yaml (OpenAPI 3.1). Live health: https://api.tikdataapi.com/status (JSON) and https://tikdataapi.com/status.
SDKs: npm tikdataapi (TypeScript), PyPI tikdataapi (Python).
Batches: 100 profiles or 100 videos per call, or the newest videos of 20 accounts.
Every response has credits_charged, balance_remaining, cache and request_id. Errors are JSON with a stable code.
Every profile, video, comment and hashtag has collected_at: the time we read it from TikTok (UTC). An object from cache keeps the time of its own read.
Image addresses (avatar_url, cover_url) are signed by TikTok and stop working after some days: store the image, not the address.
Not affiliated with TikTok or ByteDance.


---

# Quickstart

Source: https://tikdataapi.com/docs

tikdataapi.com is a read-only HTTP API for public TikTok data: profiles, videos, the videos of an account,
comments, replies, hashtags, video and account search, follower and following lists, sounds and their videos,
reposts, playlists, related videos, trending videos, sound, live and hashtag search, the live state of an account,
and the transcripts of videos. One credit is one profile, one video, one comment, one hashtag, one sound, one playlist, one
live room or one transcript returned.
Empty results and failed requests cost nothing. You need no TikTok account, no TikTok login and no cookies.
tikdataapi.com is not affiliated with TikTok or ByteDance.

## 1. Get a key [#1-get-a-key]

Sign in at [tikdataapi.com/dashboard](https://tikdataapi.com/dashboard) with your email. No password: you get a six-digit
code. Create a key there. Every new account starts with 1,000 free credits.

## 2. Make a request [#2-make-a-request]

Send the key in the `x-api-key` header.

```bash
curl "https://api.tikdataapi.com/v1/users/tiktok" \
  -H "x-api-key: tt_live_..."
```

```json
{
  "data": {
    "id": "107955",
    "username": "tiktok",
    "sec_uid": "MS4wLjABAAAAv7iSuuXDJGDvJkmH_vz1qkDZYo1apxgzaxdBSeIuPiM",
    "nickname": "TikTok",
    "verified": true,
    "private": false,
    "followers": 92400000,
    "following": 2,
    "likes": 465300000,
    "videos": 1180,
    "collected_at": "2026-12-02T08:55:12Z"
  },
  "items": 1,
  "credits_charged": 1,
  "balance_remaining": 999,
  "cache": "miss",
  "request_id": "3d4f3d1c-..."
}
```

Every response carries `items`, `credits_charged`, `balance_remaining`, `cache` and `request_id`.
Keep `request_id` when you report a problem.

Every object carries `collected_at`: the time we read it from TikTok, in UTC. Plays, likes and follower counts
change, so they are the counts of that moment. An object served from cache keeps the time of its own read.

## 3. Read the videos of an account [#3-read-the-videos-of-an-account]

```bash
curl "https://api.tikdataapi.com/v1/users/tiktok/videos?count=16" \
  -H "x-api-key: tt_live_..."
```

Pinned videos come first, then the newest. 1 credit per video. The response has `next_cursor` while there are
more videos: send it back as `cursor`. See [Pagination](/docs/pagination).

## Endpoints [#endpoints]

| Endpoint | Returns | Credits |
|---|---|---|
| `GET /v1/users/{user}` | one profile, by username or sec_uid | 1 |
| `GET /v1/users/{user}/videos` | the videos of an account, pinned first, then newest first | 1 per video |
| `GET /v1/videos/{id}` | one video | 1 |
| `GET /v1/videos/{id}/comments` | the comments of a video | 1 per comment |
| `GET /v1/videos/{id}/comments/{comment_id}/replies` | the replies to a comment | 1 per reply |
| `GET /v1/hashtags/{name}` | one hashtag, with the count of its videos and their plays | 1 |
| `GET /v1/hashtags/{name}/videos` | the videos of a hashtag | 1 per video |
| `GET /v1/search/videos?query=` | the videos that the general search of TikTok finds | 1 per video |
| `GET /v1/search/users?query=` | the accounts that the account search of TikTok finds | 1 per account |
| `GET /v1/users/{user}/followers` | the accounts that follow an account | 1 per profile |
| `GET /v1/users/{user}/following` | the accounts that an account follows | 1 per profile |
| `GET /v1/users/{user}/reposts` | the videos that an account reposted | 1 per video |
| `GET /v1/users/{user}/playlists` | the playlists of an account | 1 per playlist |
| `GET /v1/playlists/{id}/videos` | the videos of a playlist | 1 per video |
| `GET /v1/music/{id}` | one sound, with the count of its videos (rounded by TikTok) | 1 |
| `GET /v1/music/{id}/videos` | the videos that use a sound | 1 per video |
| `GET /v1/videos/{id}/related` | the videos that TikTok shows next to a video, one page | 1 per video |
| `GET /v1/trending/videos` | the explore feed of TikTok for a logged-out visitor, a new set on each read | 1 per video |
| `GET /v1/search/music?query=` | the sounds that the sound search of TikTok finds | 1 per sound |
| `GET /v1/search/live?query=` | the live rooms that match a keyword | 1 per room |
| `GET /v1/users/{user}/live` | whether an account is live now: room, title, viewers, start time | 1 |
| `GET /v1/videos/{id}/transcript` | the subtitles of a video, as segments and text | 1 |
| `GET /v1/search/hashtags?query=` | the hashtags of the videos that the general search finds, most used first | 1 per hashtag |
| `POST /v1/users/batch` | up to 100 profiles, by username | 1 per profile found |
| `POST /v1/videos/batch` | up to 100 videos, by id | 1 per video found |
| `POST /v1/users/videos/batch` | the latest videos of up to 20 accounts | 1 per video |
| `GET /v1/me` | your balance and rate limit | 0 |

`{user}` takes a username, with or without `@`, or a sec_uid. Search is the general video search and the account
search of TikTok, and sound and live search. TikTok gives a logged-out visitor no hashtag search of its own:
hashtag search ranks the hashtags of the videos of the general search, and its counts are of those videos, not the
totals of TikTok. A live room is data, not a stream. Search, the follower lists, sounds, reposts, playlists,
related videos, trending videos, live, transcripts and hashtag search are new, and their limits are not measured
yet. [What you can read](/docs/coverage) has the
full list. The full contract is in the [API reference](/reference).


---

# Authentication

Source: https://tikdataapi.com/docs/authentication

## The key [#the-key]

A key looks like `tt_live_` followed by 32 characters. It is shown once when created. Only a hash is stored on our side.
Send it in the `x-api-key` header, or as `Authorization: Bearer tt_live_...`.

A key is tied to one wallet. Several keys can share a wallet, for example one per environment.

The key is for this API only. You need no TikTok account, and you never give us a TikTok login or cookies.

## Rate limit [#rate-limit]

The limit is per account, shared by all its keys. It follows the total you have paid over the life of the
account, and it only goes up.

| Total paid | Requests per second |
|---|---|
| $0 | 1 |
| $10 or more | 20 |
| $50 or more | 50 |
| $200 or more | 100 |
| $600 or more | 200 |

Five starter packs count the same as one builder pack. A small pack after a large one changes nothing.
Above the limit the API answers `429` with a `retry-after` header. Nothing is charged. Need more?
Write to hello@tikdataapi.com.

### Read the headers instead of guessing [#read-the-headers-instead-of-guessing]

Every response carries the limit and what is left of it, so a client never has to
discover its ceiling by hitting it. The header names come from the IETF draft
[RateLimit header fields for HTTP](https://datatracker.ietf.org/doc/draft-ietf-httpapi-ratelimit-headers/):

```http
RateLimit: limit=20, remaining=19, reset=1
RateLimit-Policy: "per-second"; q=20; w=1
```

These are on refusals too, and on a `401`, where `RateLimit-Policy` quotes the rate
an account starts on. A `429` adds `Retry-After` in whole seconds.

The keyless endpoints — `GET /`, `/status`, `/healthz` and `/openapi.yaml` on
`api.tikdataapi.com` — have their own ceiling of 10 requests per second per address,
reported under the policy name `public`. No key is needed for them and none is
counted against your account.

The limit counts requests. Cached and batch requests run at the full rate. A read that is not in cache goes
to TikTok, so a burst of many different reads that are not in cache takes longer than the rate limit
alone suggests. A list call with a `count` above one TikTok page reads TikTok more than once, and takes
longer too: see [Pagination](/docs/pagination).

### Calls in progress [#calls-in-progress]

One account can have 16 reads of TikTok in progress at the same time. A further call waits for a place for up
to 5 seconds. If no place comes free, the API answers `503` with the code `busy` and `retry-after: 2`, and
nothing is charged. A response served from cache does not count. If you get `busy`, send fewer calls at
the same time.

## Check a key [#check-a-key]

```bash
curl https://api.tikdataapi.com/v1/me -H "x-api-key: tt_live_..."
```

```json
{ "customer_id": "...", "key_prefix": "tt_live_GPE4", "balance": 4895.5, "rate_limit_qps": 20 }
```

## Keep it secret [#keep-it-secret]

Never ship the key in a browser or a mobile app. Call the API from your server and put your own auth in front.
Revoke a leaked key in the [dashboard](https://tikdataapi.com/dashboard) and create a new one.


---

# Credits and billing

Source: https://tikdataapi.com/docs/credits

One credit is one profile, one video, one comment, one reply, one hashtag, one sound, one playlist, one live room or
one transcript returned to you. In video search one video is one credit, in account search one account is one
credit, in a follower or following list one profile is one credit, in the playlists of an account one playlist is
one credit, in sound search one sound is one credit, in live search one live room is one credit, and in hashtag
search one hashtag is one credit. You buy credits in
packs and spend them at any pace.

## Packs [#packs]

| Pack | Price | Credits | Per 1,000 |
|---|---|---|---|
| Free | $0 | 1,000, once | $0 |
| Starter | $10 | 80,000 | $0.125 |
| Builder | $50 | 500,000 | $0.100 |
| Growth | $200 | 2,500,000 | $0.080 |
| Scale | $600 | 10,000,000 | $0.060 |

Invoice and bank transfer from $500, and Enterprise packs from $2,000 with a signed SLA: hello@tikdataapi.com.

## Buying a pack [#buying-a-pack]

Card checkout runs on Stripe. Ask the API for a checkout link and open it:

```bash
curl -X POST https://api.tikdataapi.com/v1/billing/checkout \
  -H "x-api-key: $KEY" -H "content-type: application/json" \
  -d '{"pack":"builder"}'
```

```json
{ "url": "https://checkout.stripe.com/c/pay/cs_...", "pack": "builder", "usd": 50, "credits": 500000 }
```

The credits land in the wallet within seconds of payment, and the rate limit rises to the pack's. Check with `/v1/me`.

## Rules [#rules]

- **Credits never expire.** Paid or free, they stay in the wallet until you spend them.
- **No per-call minimum.** A request that returns nothing costs nothing: the video list of a private account,
  a video with no comments, a search with no result, the end of a list.
- **Failed requests are free.** Any status other than `200` charges zero.
- **Lookups are free.** A list read by username or by hashtag name first changes the name to an id. That lookup
  costs nothing.
- **Cache hits cost half.** Responses are cached for a short time per endpoint; a hit is marked `"cache": "hit"`.
- **`fresh=true` bypasses the cache.** An item that has a cached copy costs double and is marked
  `"cache": "bypass"`. An item with no cached copy costs the normal price.
- A charge never takes the balance below zero. At zero the API answers `402` with a link to buy more.
- One wallet per account. All packs land in the same balance; the oldest credits are spent first.
- Full refund of an unused pack within 14 days, on request to hello@tikdataapi.com.

## Price per item [#price-per-item]

| Item | Credits |
|---|---|
| Profile, also in account search and in a follower or following list | 1 |
| Video, from any endpoint, search included | 1 |
| Comment or reply | 1 |
| Hashtag, also in hashtag search | 1 |
| Playlist, in the playlists of an account | 1 |
| Sound, also in sound search | 1 |
| Live room, in live search | 1 |
| Live state of an account, live or not | 1 |
| Transcript of a video | 1 |
| Cached item | half of the above |
| `fresh=true` item that has a cached copy | double the above |
| `fresh=true` item with no cached copy | the same as above |
| Empty result, error, `404` | 0 |

## Cache times [#cache-times]

| Read | In cache for |
|---|---|
| Profile | 10 minutes |
| Video | 5 minutes |
| Videos of an account | 2 minutes |
| Comments and replies | 2 minutes |
| Hashtag | 10 minutes |
| Videos of a hashtag | 5 minutes |
| Video search, account search, followers, following | 5 minutes |
| Sound, playlists of an account | 10 minutes |
| Videos of a sound, videos of a playlist, related videos | 5 minutes |
| Reposts of an account, trending videos | 2 minutes |
| Sound search | 5 minutes |
| Live search, live state of an account | 1 minute |
| Transcript | 10 minutes |
| Hashtag search | 5 minutes |

The cache is shared by the single endpoints and the batches. Poll less often than these times and every read
is new.

## Reading the bill [#reading-the-bill]

Every response has `credits_charged` and `balance_remaining`. The same numbers are in the `x-credits-charged` and
`x-balance-remaining` headers, so a proxy can meter without parsing the body.

## SLA credit [#sla-credit]

For each full hour where the [status page](/status) shows success under 99.9 percent, every customer who made a failed
request in that hour gets 2 percent of their last pack back as credits. The number that counts is the outside
probe, which calls the public API every minute from a different network.


---

# Pagination

Source: https://tikdataapi.com/docs/pagination

List endpoints return a page and, when there is more, a `next_cursor`. Pass it back as `cursor` to get the next page.

```bash
curl "https://api.tikdataapi.com/v1/users/tiktok/videos?count=16" -H "x-api-key: $KEY"
# ... "next_cursor": "MTczMjk4NjEz..."
curl "https://api.tikdataapi.com/v1/users/tiktok/videos?count=16&cursor=MTczMjk4NjEz..." -H "x-api-key: $KEY"
```

| Endpoint | `count` default | `count` maximum | Order |
|---|---|---|---|
| `/v1/users/{user}/videos` | 16 | 50 | pinned videos first, then newest first |
| `/v1/videos/{id}/comments` | 20 | 50 | the order of TikTok: pinned first, then the most relevant |
| `/v1/videos/{id}/comments/{comment_id}/replies` | 20 | 50 | oldest first |
| `/v1/hashtags/{name}/videos` | 30 | 50 | the order of the hashtag page on TikTok: popular, not newest first |
| `/v1/search/videos` | 12 | 50 | the order of the general search of TikTok |
| `/v1/search/users` | 10 | 50 | the order of the account search of TikTok |
| `/v1/search/music` | 12 | 50 | the order of the sound search of TikTok |
| `/v1/search/live` | 12 | 50 | the order of the live search of TikTok |
| `/v1/users/{user}/followers` | 30 | 50 | newest first, as TikTok gives them |
| `/v1/users/{user}/following` | 30 | 50 | newest first, as TikTok gives them |
| `/v1/users/{user}/reposts` | 16 | 50 | the order of TikTok |
| `/v1/users/{user}/playlists` | 20 | 50 | the order of TikTok |
| `/v1/playlists/{id}/videos` | 30 | 50 | the order of the playlist |
| `/v1/music/{id}/videos` | 30 | 50 | the order of TikTok |
| `/v1/videos/{id}/related` | 16 | 16 | the order of TikTok; one page, no `next_cursor` |
| `/v1/trending/videos` | 16 | 50 | the explore feed of TikTok; no pages, no `next_cursor` |
| `/v1/search/hashtags` | 10 | 30 | most used first in the videos of the general search; no pages, no `next_cursor` |

- Cursors are opaque strings. Do not parse them or store them for longer than a session.
- A page without `next_cursor` is the last one.
- You are charged for the items you receive.
- TikTok decides how many items one of its pages holds: about 30 videos of an account,
  20 comments or replies, 30 videos of a hashtag, 12 videos of a video search, about 10 accounts of an account
  search (one page in our tests had 30), 30 accounts of a follower or following list, 12 sounds of a sound search
  and up to 12 rooms of a live search. The default `count`
  is one TikTok page, and for account search one call with the default `count` is one read of TikTok. The videos
  of an account are the exception: their default `count` of 16 is about half a TikTok page, so the next page comes
  mostly from cache at half price.
- A larger `count` fills the page from more TikTok pages in the same call, so the call takes longer. One
  call reads TikTok at most 6 times, and starts no new read after 8 seconds. A page can therefore hold fewer
  than `count` items while the list goes on. `next_cursor` then continues with no gap.
- A smaller `count` cuts a TikTok page. `next_cursor` then continues from the cut with no gap, and the rest of
  that TikTok page comes from cache at half price. Pass cursors back as they are.
- The video list of a private account is empty, and so are its reposts and playlists. The comment list of a
  video with comments turned off is empty too. All are free.
- Three lists have no pages. `/v1/videos/{id}/related` is one TikTok page of up to 16 videos. `/v1/trending/videos`
  is the explore feed of TikTok for a logged-out visitor: each read of TikTok gives a new set of about 16 videos,
  and a larger `count` reads more sets in the same call and drops repeated videos. `/v1/search/hashtags` ranks the
  hashtags of about 24 videos of the general search, up to 30. None of them takes a `cursor`.
- `POST /v1/users/videos/batch` gives the first page of up to 20 accounts at once, 1 to 16 videos for each.
  The `next_cursor` of an entry continues that list on `/v1/users/{user}/videos`. See
  [Batch reads](/docs/batch).


---

# What you can read

Source: https://tikdataapi.com/docs/coverage

tikdataapi.com reads what a logged-out visitor of tiktok.com can see. You need no TikTok account, no TikTok
login and no cookies, and we use none for you. tikdataapi.com is not affiliated with TikTok or ByteDance.

## What you can read [#what-you-can-read]

| Data | Endpoint | Notes |
|---|---|---|
| A profile | `GET /v1/users/{user}` | by username or sec_uid: bio, verified and private state, counts of followers, following, likes and videos |
| Up to 100 profiles | `POST /v1/users/batch` | by username |
| The videos of an account | `GET /v1/users/{user}/videos` | pinned videos first, then newest first |
| The latest videos of up to 20 accounts | `POST /v1/users/videos/batch` | 1 to 16 videos for each account |
| A video | `GET /v1/videos/{id}` | caption, author, sound, hashtags, mentions, counts of plays, likes, comments, shares and saves |
| Up to 100 videos | `POST /v1/videos/batch` | by id |
| The comments of a video | `GET /v1/videos/{id}/comments` | in the order of TikTok: pinned first, then the most relevant |
| The replies to a comment | `GET /v1/videos/{id}/comments/{comment_id}/replies` | oldest first |
| A hashtag | `GET /v1/hashtags/{name}` | how many videos use it, and how many plays they have |
| The videos of a hashtag | `GET /v1/hashtags/{name}/videos` | in the order of the hashtag page on TikTok: popular, not newest first |
| Videos for a keyword | `GET /v1/search/videos?query=` | the general ("Top") search of TikTok, in the order of TikTok; videos only |
| Accounts for a keyword | `GET /v1/search/users?query=` | the account search of TikTok (the "Users" tab), in the order of TikTok; each entry is a short profile |
| The followers of an account | `GET /v1/users/{user}/followers` | newest first, as TikTok gives them; each entry is a profile |
| The accounts an account follows | `GET /v1/users/{user}/following` | newest first, as TikTok gives them; each entry is a profile |
| A sound | `GET /v1/music/{id}` | title, author, album, duration, whether it is an original sound, the account of the artist or of the maker, and how many videos use it (rounded by TikTok) |
| The videos of a sound | `GET /v1/music/{id}/videos` | the videos that use the sound, in the order of TikTok |
| The reposts of an account | `GET /v1/users/{user}/reposts` | the videos that an account reposted, in the order of TikTok |
| The playlists of an account | `GET /v1/users/{user}/playlists` | id, name, count of videos, cover and author of each playlist |
| The videos of a playlist | `GET /v1/playlists/{id}/videos` | in the order of the playlist |
| Related videos | `GET /v1/videos/{id}/related` | the videos that TikTok shows next to a video: one page of up to 16, with no next page |
| Trending videos | `GET /v1/trending/videos` | the explore feed of TikTok for a logged-out visitor: up to 50 in one call, with no pages |
| Sounds for a keyword | `GET /v1/search/music?query=` | the sound search of TikTok, in the order of TikTok: id, title, author, album, duration and cover of each sound |
| Live rooms for a keyword | `GET /v1/search/live?query=` | the live search of TikTok, in the order of TikTok: room id, title, viewers now, start time, cover and host of each room |
| Whether an account is live | `GET /v1/users/{user}/live` | `live: true` with the room id, title, viewers now and start time, or `live: false` |
| The transcript of a video | `GET /v1/videos/{id}/transcript` | the subtitles of a video, as segments with start and end times and as one text; `lang` picks a language |
| Hashtags for a keyword | `GET /v1/search/hashtags?query=` | the hashtags of the videos that the general search finds, most used first: name, how many of those videos use it, and the sum of their plays |

A photo post is a video with `"type": "photo"`: a set of images with a sound. Its `duration` is the length of the
sound.

## Search and follower lists are new [#search-and-follower-lists-are-new]

Video search and the follower and following lists are new on 2026-12-02, and account search is new on the same
day. Tests showed that TikTok gives them to a logged-out reader. Their limits are not measured yet:

- how many reads TikTok allows before it asks for a captcha or blocks a reader;
- how many pages of one search, and how deep a follower list, TikTok lets us read;
- what TikTok gives for a private account, or for an account that hides the accounts it follows.

The [status page](/status) does not check these four reads yet. A read that TikTok refuses is a `503` with
`Retry-After`, and costs nothing, as for every other read.

## Sounds, reposts, playlists, related and trending videos are new [#sounds-reposts-playlists-related-and-trending-videos-are-new]

These seven reads are new on 2026-12-03. A test that day showed that TikTok gives them to a logged-out reader.
Their limits are not measured yet, and the [status page](/status) does not check them yet. What to know:

- **Sounds.** The id of a sound is the number at the end of its address,
  `tiktok.com/music/<name>-<id>`, and the `id` of the `music` of a video. `videos`, the count of videos that use
  the sound, is rounded by TikTok (for example 73900). `artist_username` is the official account of the artist of
  a song; `author_username` is the account that made an original sound.
- **Playlists.** The `id` of an entry of `/v1/users/{user}/playlists` is the id for
  `/v1/playlists/{id}/videos`. The playlists and the reposts of a private account are an empty list, and free.
- **Related videos.** TikTok gives one page of up to 16 videos, and no next page: there is no `cursor`.
- **Trending videos.** This is the explore feed of TikTok for a logged-out visitor. It has no cursor and no
  pages: each read of TikTok gives a new set of videos. A call with `count` above 16 reads more sets and drops
  the videos it has already given, up to 50. A call inside the cache time (2 minutes) gets the same set from
  cache at half price; `fresh=true` reads a new set.

## Sound search, live and transcripts are new [#sound-search-live-and-transcripts-are-new]

These four reads are new on 2026-12-03. A test that day showed that TikTok gives them to a logged-out reader.
Their limits are not measured yet, and the [status page](/status) does not check them yet. What to know:

- **Sound search.** A page of TikTok holds 12 sounds. The `id` of an entry is the id for `/v1/music/{id}` and
  `/v1/music/{id}/videos`. `original` and `videos`, the count of videos that use the sound, are there only when
  TikTok gives them.
- **Live rooms.** A live room is the data about a live broadcast: `room_id`, `title`, `viewers` (the viewers
  now), `started_at`, `cover_url` and the host as `author`. There is no stream URL: you get the data about the
  room, not the stream. A page of live search holds at most 12 rooms, often fewer. For an account that is not live,
  `/v1/users/{user}/live` gives `live: false` and no room, and costs 1 credit, as every answer does. Both reads
  stay in cache for 1 minute.
- **Transcripts.** A transcript is the subtitles that TikTok has for a video, often made by speech recognition
  (`source: "ASR"`). `segments` holds each line with its `start` and `end` in seconds, and `text` is all the lines
  in one string. `languages` lists the languages of the video. `lang` picks one, by its full code (`eng-US`) or
  its first part (`eng`); with no `lang` you get the speech-recognition transcript, else the first one. A video
  with no subtitles is a `404` `not_found` with the reason `unavailable`, and costs nothing.

## Hashtag search is new [#hashtag-search-is-new]

Hashtag search is new on 2026-12-03. TikTok gives a logged-out visitor no hashtag search of its own, so
`/v1/search/hashtags` reads about 24 videos of the general search (two TikTok pages, as `/v1/search/videos`) and
ranks the hashtags of those videos. What to know:

- **Order.** By `result_videos`, the number of those videos that use the hashtag, then by `result_plays`, the sum
  of their plays, then by first use.
- **Counts.** `result_videos` and `result_plays` are of those search videos only, not the totals of TikTok. For
  the totals, read `/v1/hashtags/{name}` with the `name` of an entry.
- **Pages.** `count` is 1 to 30, 10 by default; a larger number gives 30. There is no cursor and no next page.
- **Cache.** The answer stays in cache for 5 minutes, apart from the cache of `/v1/search/videos`.

## What you cannot read [#what-you-cannot-read]

| Not available | Why |
|---|---|
| Filters and sorting of the Videos tab of search | TikTok ignores them for a logged-out visitor: other sort orders and dates gave the same videos. Video search here is the general ("Top") search, in the order of TikTok. |
| Liked videos | TikTok gives a logged-out visitor no items, also for public accounts. |
| Video files and live streams | The API gives the data about a video or a live room, and its cover image, not the video file or the stream. There is no download endpoint. |
| Posting, liking, following, commenting, direct messages | The API is read-only. It changes nothing on TikTok and reads no messages. |
| The videos of a private account | TikTok shows them only to the followers of the account. The profile comes back with `private: true`, and its video list is empty and free. |

If you need the filters of the Videos tab, tikdataapi.com does not have them. The [list of TikTok APIs](/best-tiktok-api) compares the providers.

## How to find accounts [#how-to-find-accounts]

- **From a keyword.** `/v1/search/users` gives the accounts that the account search of TikTok finds for it, each
  with its `username` and `sec_uid`.
- **From an address.** The username is in the address of a profile: `tiktok.com/@tiktok`. The id of a video is
  the number at the end of its address: `tiktok.com/@tiktok/video/7106594312292453675`.
- **From a video.** `author` is the account that posted it, `mentions` holds the usernames in the caption, and
  `hashtags` holds its hashtags.
- **From a hashtag.** `/v1/hashtags/{name}/videos` gives the videos that TikTok shows for it, each with its
  `author`.
- **From the videos of a keyword.** `/v1/search/videos` gives the videos that TikTok finds for it, each with its
  `author`.
- **From an account.** `/v1/users/{user}/followers` and `/v1/users/{user}/following` give the accounts around it,
  each with its `username` and `sec_uid`.
- **From comments.** Each comment has its `author`, with `username` and `sec_uid`.
- **From a sound.** `/v1/music/{id}` gives `artist_username` or `author_username`, and `/v1/music/{id}/videos`
  gives the videos that use the sound, each with its `author`.
- **From live search.** `/v1/search/live` gives the live rooms for a keyword, each with its host as `author`.

Put the usernames you collect into `/v1/users/batch`, 100 in one call.

## How fresh the data is [#how-fresh-the-data-is]

Every object carries `collected_at`: the time we read it from TikTok, in UTC. The counts are those of that
moment. An object from cache keeps the time of its own read.

| Read | In cache for |
|---|---|
| Profile | 10 minutes |
| Video | 5 minutes |
| Videos of an account, comments, replies | 2 minutes |
| Hashtag | 10 minutes |
| Videos of a hashtag | 5 minutes |
| Video search, account search, followers, following | 5 minutes |
| Sound, playlists of an account | 10 minutes |
| Videos of a sound, videos of a playlist, related videos | 5 minutes |
| Reposts of an account, trending videos | 2 minutes |
| Sound search | 5 minutes |
| Live search, live state of an account | 1 minute |
| Transcript | 10 minutes |
| Hashtag search | 5 minutes |

A cache hit costs half. `fresh=true` reads TikTok again: 2x for an item that has a cached copy, the normal price
for one that has none.

## How exact the counts are [#how-exact-the-counts-are]

TikTok rounds some counts before it sends them. We pass on the most exact number that TikTok gives:

| Object | Counts |
|---|---|
| A profile from `GET /v1/users/{user}` or `POST /v1/users/batch` | exact |
| The `author` of a video | rounded: read the profile for the exact counts |
| An entry of a follower or following list | may be rounded: read the profile for the exact counts |
| An entry of account search | `followers` is rounded (for example 1100000), `likes` is exact; there is no `following`, no `videos` count and no `private` flag: read the profile for them |
| A video, alone or in a list | `plays`, `likes`, `comments` and `shares` of 10,000 or more are rounded to hundreds; `saves` is exact |
| A hashtag | exact |
| An entry of hashtag search | `result_videos` and `result_plays` count the videos of the search only, not all of TikTok: read the hashtag for its totals |
| A sound | `videos` is rounded by TikTok (for example 73900) |

## Images [#images]

`avatar_url`, `cover_url` and the other image addresses point to the image servers of TikTok. They carry a
signature and stop working after some days. Store the image, not the address. In account search, `avatar_url` is
the small avatar, 100x100.

## Usernames and ids [#usernames-and-ids]

`{user}` takes a username, with or without `@`, or a sec_uid. The `id` and the `sec_uid` of an account stay the
same when the username changes: keep one of them for data you store. A request by sec_uid needs no lookup of
the profile. A username is changed to the sec_uid through the profile, and that lookup is free.

The account whose username is `batch` is at `/v1/users/@batch`.

Do you need something that is not here? Write to hello@tikdataapi.com.


---

# Batch reads

Source: https://tikdataapi.com/docs/batch

Three endpoints take a list instead of one username or id. They cost the same per object as the single
endpoints, answer in one round trip, and never charge for an input that returned nothing.

| Endpoint | Input | Max | Credits |
|---|---|---|---|
| `POST /v1/users/batch` | `usernames` | 100 | 1 per profile found |
| `POST /v1/videos/batch` | `ids` (video ids) | 100 | 1 per video found |
| `POST /v1/users/videos/batch` | `users` (usernames or sec_uids), `count` | 20 | 1 per video returned |

All three also accept `GET` with a comma list: `/v1/users/batch?usernames=tiktok,nba,espn`,
`/v1/videos/batch?ids=7106594312292453675`, `/v1/users/videos/batch?users=tiktok,nba&count=3`.

## Request [#request]

```bash
curl -X POST https://api.tikdataapi.com/v1/users/batch \
  -H "x-api-key: $KEY" -H "content-type: application/json" \
  -d '{"usernames": ["tiktok", "nba", "nobody_here_12345"]}'
```

```json
{
  "data": [
    { "id": "107955", "username": "tiktok", "followers": 92400000, "...": "..." },
    { "username": "nba", "...": "..." }
  ],
  "errors": [
    { "input": "nobody_here_12345", "code": "not_found", "message": "no such account", "reason": "nonexistent" }
  ],
  "items": 2,
  "credits_charged": 2,
  "balance_remaining": 997,
  "cache": "miss",
  "cache_hits": 0,
  "request_id": "3d4f3d1c-..."
}
```

## Rules [#rules]

- `data` holds the objects that were found, in input order. Every input that returned nothing is in `errors`
  with a `code`: `not_found`, `no_credits`, `access_denied`, `upstream_rate_limited`, `upstream_error`,
  `request_rejected`, `bad_request` or `busy`.
- A banned account is a `not_found` with `"reason": "banned"`. An account that was deleted or never existed is a
  `not_found` with `"reason": "nonexistent"`: TikTok does not tell those two apart. A private account is found,
  with `private: true`. In the videos batch, a deleted, private or removed video is in `errors` with its
  `reason`. The [`not_found` section](/docs/errors#not_found) has each `reason`.
- Duplicates are folded, with no regard to case and to a leading `@`. `@TikTok` and `tiktok` are the same
  username.
- The cache is shared with the single endpoints. An object read in the last 10 minutes (profiles) or 5 minutes
  (videos) is served from cache at half price; `cache_hits` says how many, and `cache` is `mixed` when a batch
  has both.
- When the balance covers only part of the list, the API fetches what it can pay for and returns the rest as
  `no_credits`. Send those again after a top-up.
- When nothing is found and every failure is transient, the answer is `503` with `retry-after`, and nothing is
  charged.
- `fresh=true` reads TikTok again for the whole list. An item that has a cached copy costs 2x; an item with no
  cached copy costs the normal price.

## Latest videos of many accounts [#latest-videos-of-many-accounts]

`POST /v1/users/videos/batch` gives the newest videos of up to 20 accounts in one call, by username or sec_uid.
`count` is the number of videos for each account, 1 to 16, default 3. The videos are the same as from
[`/v1/users/{user}/videos`](/docs/pagination): pinned videos first, then newest first.

```bash
curl -X POST https://api.tikdataapi.com/v1/users/videos/batch \
  -H "x-api-key: $KEY" -H "content-type: application/json" \
  -d '{"users": ["tiktok", "nba"], "count": 3}'
```

```json
{
  "data": [
    { "user": "tiktok", "videos": [{ "id": "...", "description": "..." }, "..."], "next_cursor": "MTczMjk4NjEz..." },
    { "user": "nba", "videos": [{ "id": "...", "description": "..." }, "..."], "next_cursor": "MTczMjk1MDc4..." }
  ],
  "errors": [],
  "items": 6,
  "credits_charged": 6,
  "balance_remaining": 991,
  "cache": "miss",
  "cache_hits": 0,
  "request_id": "3d4f3d1c-..."
}
```

- `data` has one entry for each account that was read, in input order. `user` is the username (without `@`, in
  lower case) or the sec_uid from the request. `items` is the number of videos for all accounts together, and
  that is the number of credits.
- An account with no public videos, or a private one, is an entry with an empty `videos` list. It costs nothing.
  To know which, read the profile with `/v1/users/batch`.
- An account that could not be read is in `errors` with a `code`. Send it again.
- To read more videos of one account, send the `next_cursor` of the entry to `/v1/users/{user}/videos` as `cursor`.
- The cache is shared with `/v1/users/{user}/videos`: a list read in the last 2 minutes is served at half
  price. `cache_hits` is the number of accounts served from cache.
- The wallet limit counts `count` videos for each account. Accounts that the balance does not cover come back as
  `no_credits`.
- Pinned videos come first. An account with pinned videos needs a `count` above the number of its pinned
  videos to show its newest video that is not pinned.
- For thousands of accounts, send the calls one after the other, 20 accounts in each.


---

# MCP server

Source: https://tikdataapi.com/docs/mcp

tikdataapi.com serves a hosted [MCP](https://modelcontextprotocol.io) server at `https://api.tikdataapi.com/mcp`.
Transport is Streamable HTTP. Nothing to install, nothing to run, and on most clients nothing to paste:
the server implements the MCP authorization flow, so a client signs you in through a browser and gets
its own credential. A key in the header works too, and is what a client with no browser needs.

Every tool call is one REST request under the hood, at the same price, through the same cache and rate limit.
The agent sees `credits_charged` and `balance_remaining` in every result.

## Connect [#connect]

**Claude Code**

```bash
claude mcp add --transport http tikdataapi https://api.tikdataapi.com/mcp
```

**Claude.ai and Claude Desktop**

Add `https://api.tikdataapi.com/mcp` as a custom connector in Settings. These clients have no field for a
request header, so this is the only route that reaches them.

**Cursor, Windsurf, and other clients with an MCP config file**

```json
{
  "mcpServers": {
    "tikdataapi": {
      "url": "https://api.tikdataapi.com/mcp"
    }
  }
}
```

**Clients that speak stdio only**

The [mcp-remote](https://www.npmjs.com/package/mcp-remote) bridge speaks stdio to the client and
Streamable HTTP to us, and signs in on the client's behalf.

```json
{
  "mcpServers": {
    "tikdataapi": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://api.tikdataapi.com/mcp"]
    }
  }
}
```

## Connect with a key instead [#connect-with-a-key-instead]

A client that cannot open a browser — a server, a container, a CI job — sends the key in the same header
the REST API takes, or as `Authorization: Bearer tt_live_...`.

```bash
claude mcp add --transport http tikdataapi https://api.tikdataapi.com/mcp --header "x-api-key: tt_live_..."
```

```json
{
  "mcpServers": {
    "tikdataapi": {
      "url": "https://api.tikdataapi.com/mcp",
      "headers": { "x-api-key": "tt_live_..." }
    }
  }
}
```

For mcp-remote, pass the key through the environment. The header is written with no space after the
colon: mcp-remote splits the argument on the first colon, and a space there arrives as part of the key.

```json
{
  "mcpServers": {
    "tikdataapi": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://api.tikdataapi.com/mcp", "--header", "x-api-key:${TIKDATAAPI_KEY}"],
      "env": { "TIKDATAAPI_KEY": "tt_live_..." }
    }
  }
}
```

## Signing in, for people writing clients [#signing-in-for-people-writing-clients]

An unauthenticated call to `/mcp` answers `401` with a pointer to the discovery chain, which is all a
client needs to obtain its own credential:

| Step | Where |
|---|---|
| The challenge | `WWW-Authenticate: Bearer resource_metadata="..."` on the 401 |
| Protected resource (RFC 9728) | `https://api.tikdataapi.com/.well-known/oauth-protected-resource` |
| Authorization server (RFC 8414) | `https://tikdataapi.com/.well-known/oauth-authorization-server` |
| Register a client (RFC 7591) | `https://tikdataapi.com/api/oauth/register` |
| Approve | `https://tikdataapi.com/oauth/authorize` |
| Exchange the code | `https://tikdataapi.com/api/oauth/token` |
| Disconnect (RFC 7009) | `https://tikdataapi.com/api/oauth/revoke` |

Clients are public and PKCE is required, with `S256` only. There are no scopes to choose: every tool is
read-only and there is one level of access.

What the exchange returns is an ordinary API key named after the app. It appears in the
[dashboard](https://tikdataapi.com/dashboard/keys) beside keys you made by hand, spends the same balance
at the same prices, and stops the moment you revoke it. It does not expire, and there is no refresh
token: it is the same class of credential you mint yourself, with the same revocation story.

## Tools [#tools]

| Tool | Arguments | Credits |
|---|---|---|
| `get_user` | `user` (username or sec_uid) | 1 |
| `get_users` | `usernames[]`, up to 100 | 1 per profile found |
| `get_user_videos` | `user`, `count` (default 16, up to 50), `cursor` | 1 per video |
| `get_users_videos` | `users[]` (usernames or sec_uids), up to 20, `count` 1 to 16 (default 3) | 1 per video |
| `get_video` | `id` | 1 |
| `get_videos` | `ids[]`, up to 100 | 1 per video found |
| `get_comments` | `video_id`, `count` (default 20, up to 50), `cursor` | 1 per comment |
| `get_comment_replies` | `video_id`, `comment_id`, `count` (default 20, up to 50), `cursor` | 1 per reply |
| `get_hashtag` | `name` | 1 |
| `get_hashtag_videos` | `name`, `count` (default 30, up to 50), `cursor` | 1 per video |
| `search_videos` | `query`, `count` (default 12, up to 50), `cursor` | 1 per video |
| `search_users` | `query`, `count` (default 10, up to 50), `cursor` | 1 per account |
| `get_user_followers` | `user`, `count` (default 30, up to 50), `cursor` | 1 per profile |
| `get_user_following` | `user`, `count` (default 30, up to 50), `cursor` | 1 per profile |
| `get_user_reposts` | `user`, `count` (default 16, up to 50), `cursor` | 1 per video |
| `get_user_playlists` | `user`, `count` (default 20, up to 50), `cursor` | 1 per playlist |
| `get_playlist_videos` | `playlist_id`, `count` (default 30, up to 50), `cursor` | 1 per video |
| `get_music` | `music_id` | 1 |
| `get_music_videos` | `music_id`, `count` (default 30, up to 50), `cursor` | 1 per video |
| `get_related_videos` | `video_id`, `count` (default 16, up to 16) | 1 per video |
| `get_trending_videos` | `count` (default 16, up to 50) | 1 per video |
| `search_music` | `query`, `count` (default 12, up to 50), `cursor` | 1 per sound |
| `search_live` | `query`, `count` (default 12, up to 50), `cursor` | 1 per room |
| `get_user_live` | `user` | 1 |
| `get_video_transcript` | `video_id`, `lang` (optional) | 1 |
| `search_hashtags` | `query`, `count` (default 10, up to 30) | 1 per hashtag |
| `get_balance` | | free |

Every tool takes `fresh: true` to bypass the cache: 2x for an item that has a cached copy, the normal price
for one that has none. All tools are read-only and idempotent, and are
annotated as such, so clients that auto-approve read-only tools do not prompt on every call.

`search_videos` uses the general ("Top") search of TikTok and finds videos only. `search_users` uses the account
search of TikTok (the "Users" tab) and gives short profiles; `get_user` or `get_users` gives the full, exact
profile. `search_music` uses the sound search of TikTok, and `search_live` its live search. TikTok gives a logged-out
visitor no hashtag search of its own, so `search_hashtags` reads about 24 videos of the general search and ranks
their hashtags, with no next page; its `result_videos` and `result_plays` count those videos only, not the totals
of TikTok, which `get_hashtag` gives. A sound is read by its id: the `id` of the `music` of a video, or the
number at the end of the address of a sound. `get_related_videos` gives one page with no cursor.
`get_trending_videos` gives the explore feed of TikTok for a logged-out visitor: no cursor, and a new set of
videos on each read of TikTok. `get_user_live` tells whether an account is live now; a live room is data, with no
stream URL. `get_video_transcript` gives the subtitles of a video; a video with no subtitles is a `not_found`
error and costs nothing. Search, the follower lists, sounds, reposts, playlists, related videos, trending videos,
live, transcripts and hashtag search are new, and their limits are not measured yet. See [What you can read](/docs/coverage).

## Notes [#notes]

- The server is stateless. Each request carries the key; there is no session to expire.
- A REST error (`not_found`, `no_credits`, `rate_limited`) comes back as a tool error with the same JSON body,
  so the agent can read the `code` and act on it.
- Results are the same flat `User`, `Video`, `Comment`, `Hashtag`, `MusicDetail`, `MusicSummary`, `Playlist`,
  `LiveRoom`, `Transcript` and `HashtagSummary` objects as the REST API, as JSON text.
- Keys are per account. Create one key per agent in the [dashboard](https://tikdataapi.com/dashboard) so you can
  revoke it alone.


---

# For agents

Source: https://tikdataapi.com/docs/agents

Everything an agent needs is a URL away. Pick the one that fits the client.

| Need | URL |
|---|---|
| Docs, short index | `https://tikdataapi.com/llms.txt` |
| Docs, everything in one file | `https://tikdataapi.com/llms-full.txt` |
| One docs page as Markdown | add `.md` to its URL, for example `https://tikdataapi.com/docs/coverage.md` |
| Contract, OpenAPI 3.1 | `https://api.tikdataapi.com/openapi.yaml`, or `https://tikdataapi.com/openapi.json` |
| Tools, MCP server | `https://api.tikdataapi.com/mcp` (signs itself in, or header `x-api-key`) |
| Live health, JSON | `https://api.tikdataapi.com/status` |
| Directory of all of the above | `https://api.tikdataapi.com/` |

Every docs page also answers a request with `Accept: text/markdown` in Markdown.

## Prompt to paste [#prompt-to-paste]

```text
Use the tikdataapi.com API to read public TikTok data: profiles, videos, comments, replies, hashtags, sounds,
video, account, sound, live and hashtag search, follower and following lists, reposts, playlists, related and
trending videos, whether an account is live, and video transcripts.
Docs: https://tikdataapi.com/llms-full.txt. Base URL https://api.tikdataapi.com, header x-api-key: tt_live_...
Every response has credits_charged and balance_remaining; stop when balance_remaining is 0. Errors are JSON
with a stable "code" field. Pages return next_cursor; pass it back as cursor. Find accounts with account search
(short profiles; read the full profile with /v1/users/{user}). Hashtag search ranks the hashtags of the videos of
the general search: its counts are of those videos, not the totals of TikTok (read /v1/hashtags/{name} for those).
```

## MCP in one line [#mcp-in-one-line]

```bash
claude mcp add --transport http tikdataapi https://api.tikdataapi.com/mcp
```

No key in it: the server signs the client in through a browser and it gets its own credential. Other
clients, and the header form for a machine with no browser: see [MCP server](/docs/mcp). The 27 tools are
read-only and annotated as such, so clients that auto-approve read-only tools do not prompt on every call.

## Why the API is easy for agents [#why-the-api-is-easy-for-agents]

- **Flat objects.** A `User`, a `Video`, a `Comment` and a `Hashtag` are the same shape on every endpoint. No
  wrappers to dig through.
- **Stable error codes.** `no_credits`, `not_found`, `rate_limited`, `busy`, `upstream_rate_limited`. The
  [errors page](/docs/errors) says what to do for each. Failed requests cost nothing.
- **Costs in the response.** `credits_charged` and `balance_remaining` on every call, so an agent can budget without
  a second request.
- **Time on every object.** `collected_at` says when we read it from TikTok, so an agent knows how old a count is.
- **Cursors, not page numbers.** `next_cursor` is opaque; pass it back as `cursor`. No cursor means the end.
- **Batch.** Up to 100 usernames or video ids in one call, one charge, errors per item. See [batch](/docs/batch).
- **Idempotent reads.** Everything is a read. Retrying is always safe; a repeat inside the cache window costs half.
- **A key per agent.** Make one key per agent in the [dashboard](https://tikdataapi.com/dashboard) so one can be revoked alone.


---

# SDKs

Source: https://tikdataapi.com/docs/sdks

Both clients are generated from the API's OpenAPI document, so they carry every endpoint, parameter and
response type, and they update with the API. They are thin: one HTTP call per method, no retries or state,
the same `credits_charged` and `balance_remaining` fields as the raw API.

## TypeScript [#typescript]

```bash
npm install tikdataapi
```

```ts
import { tikdataapi } from 'tikdataapi';

const api = tikdataapi({ apiKey: process.env.TIKDATAAPI_KEY! });

const { data: profile } = await api.getUser({ path: { user: 'tiktok' } });
console.log(profile?.data.followers, profile?.credits_charged);

const { data: page } = await api.getUserVideos({ path: { user: 'tiktok' }, query: { count: 16 } });
for (const v of page?.data ?? []) console.log(v.id, v.plays, v.description);

const { data: many } = await api.getUsers({ body: { usernames: ['tiktok', 'nba', 'espn'] } });
console.log(many?.items, many?.errors);

const { data: found } = await api.searchVideos({ query: { query: 'street food', count: 12 } });
for (const v of found?.data ?? []) console.log(v.id, v.author.username, v.plays);

const { data: accounts } = await api.searchUsers({ query: { query: 'cooking', count: 10 } });
for (const u of accounts?.data ?? []) console.log(u.username, u.followers, u.verified);

const { data: followers } = await api.getUserFollowers({ path: { user: 'tiktok' }, query: { count: 30 } });
for (const u of followers?.data ?? []) console.log(u.username, u.followers);

const { data: sound } = await api.getMusic({ path: { id: '6696419263248336898' } });
console.log(sound?.data.title, sound?.data.videos);

const { data: trending } = await api.getTrendingVideos({ query: { count: 16 } });
for (const v of trending?.data ?? []) console.log(v.id, v.author.username, v.plays);

const { data: sounds } = await api.searchMusic({ query: { query: 'lofi', count: 12 } });
for (const m of sounds?.data ?? []) console.log(m.id, m.title, m.author);

const { data: live } = await api.getUserLive({ path: { user: 'tiktok' } });
console.log(live?.data.live, live?.data.title, live?.data.viewers);

const { data: transcript } = await api.getVideoTranscript({ path: { id: '7708543740230536461' } });
console.log(transcript?.data.language, transcript?.data.text);

const { data: tags } = await api.searchHashtags({ query: { query: 'street food', count: 10 } });
for (const t of tags?.data ?? []) console.log(t.name, t.result_videos, t.result_plays);
```

Every call returns `{ data, error, response }`. On a status other than 2xx, `data` is undefined and `error`
holds the API error with its `code`. Node 18+, Bun, Deno, browsers, edge runtimes.

## Python [#python]

```bash
pip install tikdataapi
```

```python
import os

from tikdataapi import AuthenticatedClient
from tikdataapi.api.music import get_music
from tikdataapi.api.search import search_hashtags, search_music, search_users, search_videos
from tikdataapi.api.users import get_user, get_user_followers, get_user_live, get_user_videos, get_users
from tikdataapi.api.videos import get_trending_videos, get_video_transcript
from tikdataapi.models import (
    GetUsersBody,
    HashtagSummaryPage,
    LiveRoomResponse,
    MusicResponse,
    MusicSummaryPage,
    TranscriptResponse,
    UserBatch,
    UserPage,
    UserResponse,
    UserSummaryPage,
    VideoPage,
)

client = AuthenticatedClient(
    base_url="https://api.tikdataapi.com",
    token=os.environ["TIKDATAAPI_KEY"],
    prefix="",
    auth_header_name="x-api-key",
)

profile = get_user.sync("tiktok", client=client)
if isinstance(profile, UserResponse):
    print(profile.data.followers, profile.credits_charged)

page = get_user_videos.sync("tiktok", client=client, count=16)
if isinstance(page, VideoPage):
    for v in page.data:
        print(v.id, v.plays, v.description)

many = get_users.sync(client=client, body=GetUsersBody(usernames=["tiktok", "nba", "espn"]))
if isinstance(many, UserBatch):
    print(many.items, many.errors)

found = search_videos.sync(client=client, query="street food", count=12)
if isinstance(found, VideoPage):
    for v in found.data:
        print(v.id, v.author.username, v.plays)

accounts = search_users.sync(client=client, query="cooking", count=10)
if isinstance(accounts, UserSummaryPage):
    for u in accounts.data:
        print(u.username, u.followers, u.verified)

followers = get_user_followers.sync("tiktok", client=client, count=30)
if isinstance(followers, UserPage):
    for u in followers.data:
        print(u.username, u.followers)

sound = get_music.sync("6696419263248336898", client=client)
if isinstance(sound, MusicResponse):
    print(sound.data.title, sound.data.videos)

trending = get_trending_videos.sync(client=client, count=16)
if isinstance(trending, VideoPage):
    for v in trending.data:
        print(v.id, v.author.username, v.plays)

sounds = search_music.sync(client=client, query="lofi", count=12)
if isinstance(sounds, MusicSummaryPage):
    for m in sounds.data:
        print(m.id, m.title, m.author)

live = get_user_live.sync("tiktok", client=client)
if isinstance(live, LiveRoomResponse):
    print(live.data.live, live.data.title, live.data.viewers)

transcript = get_video_transcript.sync("7708543740230536461", client=client)
if isinstance(transcript, TranscriptResponse):
    print(transcript.data.language, transcript.data.text)

tags = search_hashtags.sync(client=client, query="street food", count=10)
if isinstance(tags, HashtagSummaryPage):
    for t in tags.data:
        print(t.name, t.result_videos, t.result_plays)
```

Every operation has `sync`, `sync_detailed`, `asyncio` and `asyncio_detailed` forms. The modules are
`api.users`, `api.videos`, `api.hashtags`, `api.music`, `api.playlists`, `api.search`, `api.account` and
`api.billing`. `get_related_videos`, `get_trending_videos` and `get_video_transcript` are in `api.videos`, and `get_user_live` is in
`api.users`. `sync` returns the
model of the answer on a 200 (`UserResponse`, `VideoPage`, ...), an `Error` model on an error status, and
`None` on a status the API reference does not list. Check the type with `isinstance`, as above.

## Methods [#methods]

| Method | Endpoint |
|---|---|
| `getMe` / `get_me` | `GET /v1/me` |
| `getUser` / `get_user` | `GET /v1/users/{user}` |
| `getUsers` / `get_users` | `POST /v1/users/batch` |
| `getUserVideos` / `get_user_videos` | `GET /v1/users/{user}/videos` |
| `getUsersVideos` / `get_users_videos` | `POST /v1/users/videos/batch` |
| `getUserFollowers` / `get_user_followers` | `GET /v1/users/{user}/followers` |
| `getUserFollowing` / `get_user_following` | `GET /v1/users/{user}/following` |
| `getUserReposts` / `get_user_reposts` | `GET /v1/users/{user}/reposts` |
| `getUserPlaylists` / `get_user_playlists` | `GET /v1/users/{user}/playlists` |
| `getUserLive` / `get_user_live` | `GET /v1/users/{user}/live` |
| `getVideo` / `get_video` | `GET /v1/videos/{id}` |
| `getVideos` / `get_videos` | `POST /v1/videos/batch` |
| `getRelatedVideos` / `get_related_videos` | `GET /v1/videos/{id}/related` |
| `getTrendingVideos` / `get_trending_videos` | `GET /v1/trending/videos` |
| `getVideoTranscript` / `get_video_transcript` | `GET /v1/videos/{id}/transcript` |
| `getComments` / `get_comments` | `GET /v1/videos/{id}/comments` |
| `getCommentReplies` / `get_comment_replies` | `GET /v1/videos/{id}/comments/{comment_id}/replies` |
| `getHashtag` / `get_hashtag` | `GET /v1/hashtags/{name}` |
| `getHashtagVideos` / `get_hashtag_videos` | `GET /v1/hashtags/{name}/videos` |
| `getMusic` / `get_music` | `GET /v1/music/{id}` |
| `getMusicVideos` / `get_music_videos` | `GET /v1/music/{id}/videos` |
| `getPlaylistVideos` / `get_playlist_videos` | `GET /v1/playlists/{id}/videos` |
| `searchVideos` / `search_videos` | `GET /v1/search/videos` |
| `searchUsers` / `search_users` | `GET /v1/search/users` |
| `searchMusic` / `search_music` | `GET /v1/search/music` |
| `searchLive` / `search_live` | `GET /v1/search/live` |
| `searchHashtags` / `search_hashtags` | `GET /v1/search/hashtags` |
| `listPacks`, `createCheckout` / `list_packs`, `create_checkout` | billing |

Video search, account search and the follower and following lists are new on 2026-12-02. An entry of account
search is a short profile (`UserSummary`) with a rounded `followers`. In an entry of a follower or following
list the counts may be rounded. `getUser` / `get_user` gives the exact ones.

Sounds, reposts, playlists, related videos and trending videos are new on 2026-12-03. `getMusic` / `get_music`
gives a `MusicDetail`; its `videos`, the count of videos that use the sound, is rounded by TikTok.
`getUserPlaylists` / `get_user_playlists` gives `Playlist` entries; pass the `id` of one to `getPlaylistVideos` /
`get_playlist_videos`. `getRelatedVideos` / `get_related_videos` (one page of up to 16) and `getTrendingVideos` /
`get_trending_videos` (up to 50) take no cursor and have no next page.

Sound search, live and transcripts are new on 2026-12-03 too. `searchMusic` / `search_music` gives `MusicSummary`
entries; pass the `id` of one to `getMusic` / `get_music`. `searchLive` / `search_live` gives `LiveRoom` entries, and
`getUserLive` / `get_user_live` gives one `LiveRoom`, with `live: false` and no room fields when the account is not
live. A `LiveRoom` has no stream URL. `getVideoTranscript` / `get_video_transcript` gives a `Transcript`: `segments`
with `start` and `end` in seconds, and `text`. Its `lang` picks a language; a video with no subtitles is a `404`.

Hashtag search is new on 2026-12-03 too. `searchHashtags` / `search_hashtags` gives `HashtagSummary` entries,
most used first in about 24 videos of the general search. Their `result_videos` and `result_plays` count those
videos only, not the totals of TikTok: pass the `name` of an entry to `getHashtag` / `get_hashtag` for those. It
takes no cursor and has no next page.

A `user` is a username, with or without `@`, or a sec_uid. Pass `next_cursor` from a page back as `cursor`.

Other languages: the [OpenAPI document](https://api.tikdataapi.com/openapi.yaml) works with any generator, and
the [MCP server](/docs/mcp) covers agents without code.


---

# Errors

Source: https://tikdataapi.com/docs/errors

Errors are JSON with a stable `code`, a human `message` and the `request_id`. No error is charged.

```json
{ "error": { "code": "no_credits", "message": "balance is zero; buy a credit pack at https://tikdataapi.com/dashboard/billing", "top_up_url": "https://tikdataapi.com/dashboard/billing" }, "request_id": "..." }
```

Match on `code`, never on `message`. The code is part of the contract and will
not change under you; the message is written for a person and may be reworded.

| Status | Code | Meaning | What to do |
|---|---|---|---|
| 400 | `bad_request` | a parameter is missing or malformed | fix the request |
| 401 | `missing_key`, `invalid_key` | no key, or a revoked key | check the header |
| 402 | `no_credits` | balance is zero | buy a pack at `error.top_up_url` |
| 403 | `email_not_allowed` | the account uses a throwaway email domain | sign up with a permanent address |
| 403 | `owner_only` | a team member's key tried to buy credits; only the account owner buys | ask the account owner to buy |
| 403 | `access_denied` | TikTok refused this object to our reader | try later, or a different object |
| 404 | `not_found` | no such account, video, comment or hashtag, or TikTok does not show it | read `error.reason` |
| 429 | `rate_limited` | over your requests-per-second limit | wait `retry-after` seconds |
| 503 | `upstream_rate_limited` | TikTok asked our reader for a captcha, or blocked its address | retry after `retry-after` seconds, with backoff |
| 503 | `busy` | 16 of your reads are in progress, or all our readers are busy | retry after `retry-after` seconds; send fewer calls at the same time |
| 502, 503 | `upstream_error` | TikTok answered with something we could not use | retry with backoff; if it persists we are already paged |
| 502 | `request_rejected` | TikTok rejected the request | retry once |
| 500 | `internal` | our bug | send us the `request_id` |

## RFC 9457 problem+json [#rfc-9457-problemjson]

Send `Accept: application/problem+json` and the same failure comes back in the
shape a generic HTTP client already understands. Nothing new is reported: `type`,
`title`, `status` and `detail` are the registered names for what `error.code` and
`error.message` already said, and the native `error` object is still there, so one
parser reads either shape.

```json
{
  "type": "https://tikdataapi.com/docs/errors#no_credits",
  "title": "Balance is zero",
  "status": 402,
  "detail": "balance is zero; buy a credit pack at https://tikdataapi.com/dashboard/billing",
  "code": "no_credits",
  "error": {
    "code": "no_credits",
    "message": "balance is zero; buy a credit pack at https://tikdataapi.com/dashboard/billing",
    "top_up_url": "https://tikdataapi.com/dashboard/billing"
  },
  "request_id": "..."
}
```

Without that header you get the native shape, which is what both SDKs read. Neither
is going away.

## Retry policy we recommend [#retry-policy-we-recommend]

Retry `503` and `502` up to three times with 2, 4 and 8 seconds between attempts. Retry a `429` after
`retry-after`. Do not retry other `4xx`. Because failed requests are free, retries never cost credits.

Read `retry-after` when it is present rather than guessing, and read `RateLimit`
on every response to throttle before a `429` happens at all. See
[Authentication](/docs/authentication) for the rate ladder.

## Every code [#every-code]

### missing_key [#missing_key]

`401`. No key was sent. Put it in `x-api-key`, or send `Authorization: Bearer tt_live_…`.
Free.

### invalid_key [#invalid_key]

`401`. The key is unknown or has been revoked. Check it has not been deleted in the
dashboard, and that you are not sending a key from another environment. Free.

### rate_limited [#rate_limited]

`429`. Over the account's requests-per-second limit, which is shared by every key
on the account. Wait `retry-after` seconds. The limit and what is left of it are on
every response in the `RateLimit` header, so a client that reads it need never hit
this. Free.

### no_credits [#no_credits]

`402`. The balance is zero. Buy a pack in the dashboard: the body carries the page as
`error.top_up_url`, so an agent can show it to a person. There is no overage and no
invoice: the API stops rather than spending money you did not agree to. Free. The account
email gets one notice when the balance reaches zero, and one when it falls under 20% of the
last pack.

### email_not_allowed [#email_not_allowed]

`403`. The account was made with a throwaway email domain. Such accounts get no credits
and no key works. Sign up again with a permanent address. Free.

### owner_only [#owner_only]

`403`. Only on `/v1/billing/checkout`. A team member made the key, and only the account
owner can buy credits. Ask the owner to buy. Free.

### bad_request [#bad_request]

`400`. Something about the request itself is wrong: a missing required parameter, a
malformed cursor, a `count` out of range, a batch list over its limit, an unparseable body. The message
names the problem. Retrying unchanged will fail again. Free.

### not_found [#not_found]

`404`. There is no such account, video, comment or hashtag, or TikTok does not show it to a
logged-out reader. Not a fault and not retryable. Free.

`error.reason` says why:

| `reason` | What it means |
|---|---|
| `nonexistent` | No such account, video, comment or hashtag, or it was deleted. TikTok does not tell those two apart. |
| `banned` | TikTok banned the account. |
| `private` | A video that only some accounts may see. |
| `removed` | TikTok removed the video for a rule of TikTok. |
| `unavailable` | Any other reason, for example a video that TikTok does not show in the country of our reader. |

A private account is not a `not_found`: its profile comes back with `private: true`, and its video list is
empty and free. The batch endpoints put the same `reason` on the item in `errors`.

```json
{ "error": { "code": "not_found", "message": "the account is banned", "reason": "banned" }, "request_id": "..." }
```

### access_denied [#access_denied]

`403`. TikTok refused to show this object to our reader. Often it is about the object and not the
account, so another read may well succeed. Free.

### upstream_rate_limited [#upstream_rate_limited]

`503`. TikTok asked our reader for a captcha, or blocked the address it reads from. Retry after
`retry-after` seconds with backoff. Free.

### busy [#busy]

`503`. Your account has 16 reads of TikTok in progress, or all our readers are in use at this moment. The
call waited up to 5 seconds for a place. Retry after `retry-after` seconds, and send fewer calls at the same
time. Free.

### upstream_error [#upstream_error]

`502` or `503`. TikTok answered with something we could not use. A `503` carries `retry-after` and is worth
a retry soon; a `502` is worth one retry. If it persists, it is already paging us. Free.

### request_rejected [#request_rejected]

`502`. TikTok rejected the shape of our request to it. Same handling as `upstream_error`. Free.

### billing_disabled [#billing_disabled]

`503`, on the checkout endpoint only. Card checkout is not configured on this deployment. Nothing you can fix
from the client. Free.

### internal [#internal]

`500`. Our bug. Send the `request_id` to hello@tikdataapi.com and we will find the exact
call in the logs. Free.


---

# Versioning

Source: https://tikdataapi.com/docs/versioning

The major version is in the path. Every endpoint begins `/v1/`, and that is the
only version marker: there is no version header, no date pinning, and no
`?version=` parameter to set.

## What can change inside v1 [#what-can-change-inside-v1]

Inside a major version we only add.

| Change | Happens inside `/v1/` |
|---|---|
| A new endpoint | yes |
| A new optional query parameter | yes |
| A new field on `User`, `Video`, `Comment`, `Hashtag` or a response envelope | yes |
| A new value in an `error.code` enum | yes |
| A field removed or renamed | no |
| A field's type changed | no |
| A parameter becoming required | no |
| A status code changing meaning | no |

**Parse defensively.** A new field is not a breaking change, so ignore what you
do not recognise rather than failing on it. Both SDKs already do. If you hand
responses to a strict schema validator, configure it to allow unknown keys.

## What happens before anything is removed [#what-happens-before-anything-is-removed]

A change that would break a caller opens `/v2/` instead of altering `/v1/`. When
that happens, `/v1/` keeps answering for **at least 12 months** from the day the
deprecation is announced, and every `/v1/` response carries the notice for the
whole of that period:

| Header | Meaning |
|---|---|
| `Deprecation` | The date the version was declared deprecated. RFC 9745. |
| `Sunset` | The earliest date it may stop answering. RFC 8594. |
| `Link: <…>; rel="deprecation"` | What changed, and how to move. |

```http
Deprecation: Wed, 01 Jul 2026 00:00:00 GMT
Sunset: Thu, 01 Jul 2027 00:00:00 GMT
Link: <https://tikdataapi.com/docs/versioning>; rel="deprecation"
```

**No header, no sunset.** The absence of `Sunset` on a response is the promise
that the version you are calling is not going away inside the notice period.
Nothing is ever removed from `/v1/` without it, so a client that watches for the
header needs no other signal. Today `/v1/` sends none: it is current.

Deprecations are also posted on [the status page](/status) and announced by email
to every account that called the affected endpoint in the previous 30 days.

## Checking from code [#checking-from-code]

```bash
curl -sS -D- -o /dev/null \
  -H "x-api-key: $TIKDATAAPI_KEY" \
  https://api.tikdataapi.com/v1/me | grep -i '^sunset\|^deprecation'
```

An empty result means the version is current. Anything else is the date you have
to move by, and the `Link` header is where to read what changed.

## The machine-readable contract [#the-machine-readable-contract]

The same policy is stated in the OpenAPI document, which is the thing to generate
clients from:

- [https://tikdataapi.com/openapi.json](https://tikdataapi.com/openapi.json)
- [https://api.tikdataapi.com/openapi.yaml](https://api.tikdataapi.com/openapi.yaml)
