# TikTok

Canonical: https://monsterapi.co/docs/tiktok

Read public TikTok data at `https://api.monsterapi.co/tiktok/api` with a MonsterAPI bearer key.
This guide describes TikTok API contract version `0.9.48`.
The API provides 28 paths: 17 web paths and 11 mobile paths. Requests don’t carry a TikTok account or session.

TikTok can restrict anonymous access to an operation or object. Handle the documented refusals as well as successful responses.

## First request

Request a page of recommendations without an account identifier:

```shell
curl --get -H "Authorization: Bearer $MONSTERAPI_KEY" \
  --data-urlencode "count=1" \
  "https://api.monsterapi.co/tiktok/api/mobile/feed"
```

For a known handle, request [GET /web/user/detail](https://monsterapi.co/docs/api/tiktok-users#tiktok-user-profile) with `uniqueId`, without `@`.
Encode query values separately and preserve the spelling and case of every input key.
For example, `secUid` and `sec_user_id` belong to different routes; they aren’t interchangeable parameter names.

## Choose the information

The [API reference](https://monsterapi.co/docs/api) lists the required inputs and response fields for every TikTok route.
Several routes return overlapping information. Choose by the object, required parameters and available continuation.

Web and mobile routes have separate contracts. Select a `/web` or `/mobile` route explicitly for each request.
A request does not switch between these routes. A refusal from one does not establish that another returns the same information.
All paths below are relative to `/tiktok/api`.

| Information                   | GET paths                                                                                                                                                                                                                                                                                                              |
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| User profiles                 | [GET /web/user/detail](https://monsterapi.co/docs/api/tiktok-users#tiktok-user-profile)                                                                                                                                                                                                                                                          |
| Followers and following       | [GET /web/user/list](https://monsterapi.co/docs/api/tiktok-users#tiktok-user-relations), [GET /mobile/relation/follower/list](https://monsterapi.co/docs/api/tiktok-users#tiktok-followers), [GET /mobile/relation/following/list](https://monsterapi.co/docs/api/tiktok-users#tiktok-following)                                                                                                     |
| Author publications           | [GET /web/post/item_list](https://monsterapi.co/docs/api/tiktok-publications#tiktok-publications-by-secuid), [GET /mobile/post/item_list](https://monsterapi.co/docs/api/tiktok-publications#tiktok-publications-by-sec-user-id)                                                                                                                                           |
| Publication details           | [GET /web/item/detail](https://monsterapi.co/docs/api/tiktok-publications#tiktok-publication-details)                                                                                                                                                                                                                                            |
| Stories                       | [GET /web/story/item_list](https://monsterapi.co/docs/api/tiktok-publications#tiktok-author-stories)                                                                                                                                                                                                                                             |
| Recommendations               | [GET /web/recommend/item_list](https://monsterapi.co/docs/api/tiktok-publications#tiktok-recommendations-2), [GET /mobile/feed](https://monsterapi.co/docs/api/tiktok-publications#tiktok-recommendations), [GET /mobile/full/feed](https://monsterapi.co/docs/api/tiktok-publications#tiktok-for-you-publications)                                                                                  |
| Publication context           | [GET /mobile/public/item/locate](https://monsterapi.co/docs/api/tiktok-publications#tiktok-publications-around-an-item), [GET /mobile/context/feed](https://monsterapi.co/docs/api/tiktok-publications#tiktok-publication-context)                                                                                                                                         |
| Comments and replies          | [GET /web/comment/list](https://monsterapi.co/docs/api/tiktok-comments#tiktok-publication-comments-2), [GET /web/comment/reply/list](https://monsterapi.co/docs/api/tiktok-comments#tiktok-comment-replies-2), [GET /mobile/comment/list](https://monsterapi.co/docs/api/tiktok-comments#tiktok-publication-comments), [GET /mobile/comment/reply/list](https://monsterapi.co/docs/api/tiktok-comments#tiktok-comment-replies) |
| Topics and their publications | [GET /web/challenge/detail](https://monsterapi.co/docs/api/tiktok-topics#tiktok-topic-details), [GET /web/challenge/item_list](https://monsterapi.co/docs/api/tiktok-topics#tiktok-topic-publications), [GET /mobile/challenge/item_list](https://monsterapi.co/docs/api/tiktok-topics#tiktok-publications-by-ch-id)                                                                                 |
| Music and its publications    | [GET /web/music/detail](https://monsterapi.co/docs/api/tiktok-music#tiktok-music-details), [GET /web/music/item_list](https://monsterapi.co/docs/api/tiktok-music#tiktok-publications-by-musicid), [GET /mobile/music/item_list](https://monsterapi.co/docs/api/tiktok-music#tiktok-publications-by-music-id)                                                                                        |
| Search                        | [GET /web/search/user/full](https://monsterapi.co/docs/api/tiktok-search#tiktok-user-search), [GET /web/search/general/full](https://monsterapi.co/docs/api/tiktok-search#tiktok-general-search), [GET /web/search/general/preview](https://monsterapi.co/docs/api/tiktok-search#tiktok-search-suggestions)                                                                                          |
| Page information              | [GET /web/page/html](https://monsterapi.co/docs/api/tiktok-pages#tiktok-page-information)                                                                                                                                                                                                                                                        |
| Media bytes and metadata      | [GET /web/video/cdn](https://monsterapi.co/docs/api/tiktok-media#tiktok-media-bytes-and-metadata)                                                                                                                                                                                                                                                |

## Read response fields and identifiers

List and detail responses include `data`, `named` and `next_cursor`.
`data` contains public object fields. `named` contains profile, publication, comment, user, music, topic or search fields from the same response.
Unavailable named fields are `null`. Keep identifiers as strings, exactly as returned.

For `secUid`, use `named.user.sec_uid` from [GET /web/user/detail](https://monsterapi.co/docs/api/tiktok-users#tiktok-user-profile).
For `sec_user_id`, use `named.posts[].author.sec_uid` from [GET /mobile/feed](https://monsterapi.co/docs/api/tiktok-publications#tiktok-recommendations).
When a route also requires `user_id`, use `named.posts[].author.id` from that same response and author.
Identifier and cursor descriptions link to their exact response field and GET path.

For `ch_id`, use `data.aweme_list[].cha_list[].cid` from [GET /mobile/feed](https://monsterapi.co/docs/api/tiktok-publications#tiktok-recommendations).
[GET /mobile/challenge/item_list](https://monsterapi.co/docs/api/tiktok-topics#tiktok-publications-by-ch-id) defaults to `count=10`.
Some returned publications can lack topic metadata. Keep the complete returned page.

The page information response contains `title`, `canonical_url`, `meta` and `other`.
The media response contains the returned bytes as `bytes_base64`, their length as `bytes_count`, and media metadata.
[GET /web/video/cdn](https://monsterapi.co/docs/api/tiktok-media#tiktok-media-bytes-and-metadata) reads at most 1,024 bytes, beginning at byte zero.
It doesn’t download a complete video. Use a media URL from a publication response that meets the reference’s HTTPS host restrictions.
[GET /web/page/html](https://monsterapi.co/docs/api/tiktok-pages#tiktok-page-information) returns page information rather than the complete HTML source.
Response examples illustrate structure. Available fields and records depend on the requested object.

## Continue a list

For [GET /mobile/challenge/item_list](https://monsterapi.co/docs/api/tiktok-topics#tiktok-publications-by-ch-id), pass its opaque `next_cursor` unchanged as `cursor`.
Keep the same `ch_id` and `count` for continuation.

For [GET /mobile/full/feed](https://monsterapi.co/docs/api/tiktok-publications#tiktok-for-you-publications), `count` defaults to `1` and accepts values from `1` to `200`.
Its non-null `next_cursor` is an opaque v4 continuation token.

Omit `cursor` on the first Full feed request.
If `next_cursor` is not `null`, pass it unchanged as `cursor` to the same GET path.
Keep the same `count`.
An empty Full feed page returns `503` `upstream_error`, on both first pages and continuation pages.
This response does not end the list.

Take `next_cursor` from the response of the same GET path and pass it unchanged as `cursor`, keeping the same filters.
For example, take `next_cursor` from [GET /mobile/post/item_list](https://monsterapi.co/docs/api/tiktok-publications#tiktok-publications-by-sec-user-id)
and pass it to `cursor` of GET `/mobile/post/item_list`, keeping `sec_user_id` and `sort` unchanged.
An empty successful page with `next_cursor` can be followed. Stop when `next_cursor` is `null` or the response is `404` `not_found`.

For [GET /mobile/post/item_list](https://monsterapi.co/docs/api/tiktok-publications#tiktok-publications-by-sec-user-id), an empty page that indicates continuation returns `503` `upstream_error`.
This response does not end the list.

`count` is a page-size hint from 1 to 200; the returned size can differ. Records can repeat across pages.
Deduplicate by the returned object identifier if the application needs one copy of each record.

## Handle errors and credits

A `404` `not_found` ends the requested listing or reports an absent object. A `501` `requires_auth` means anonymous access isn’t available.
User search can be temporarily unavailable; handle `501` and `503` rather than treating either as an empty result.
A `500` or `503` doesn’t establish whether an object exists or a search has matches.
Follow `Retry-After` when the response supplies it. Check the input and response code before repeating a request.

Check the current operation price in the [API reference](https://monsterapi.co/docs/api) before sending a web or mobile request.
Each page is a separate operation. Responses with `2xx` or `4xx` are charged; `5xx` responses are refunded.
Gateway rejections aren’t charged. See [Authentication](https://monsterapi.co/docs/authentication), [Errors](https://monsterapi.co/docs/errors), and [Pricing](https://monsterapi.co/docs/pricing) for the shared rules.

## Public examples

Use the [API reference](https://monsterapi.co/docs/api) for ready-made public inputs and response examples.
Read [Examples](https://monsterapi.co/docs/examples) for provenance, preparation costs, task recipes, and pagination stop rules.
