> ## Documentation Index
> Fetch the complete documentation index at: https://docs.querying.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# TikTok API

> Search TikTok videos and read videos, comments with replies, creators and trending videos as JSON, with views, likes, shares, saves, comment counts and publish times.

Read public TikTok data as JSON with `POST /v1/social/tiktok/{action}`. `{action}` picks what to read. A completed request costs **0.5 credits**.

## Request

```bash theme={"theme":"css-variables"}
curl -X POST https://api.querying.ai/v1/social/tiktok/search \
  -H "Authorization: Bearer $QUERYING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "query": "coffee recipe", "limit": 1 }'
```

The request waits for the result, up to 290 seconds, and answers `200` with the result in `response`. A task still running answers `202`; poll `GET /v1/async/task/{id}` or set `webhook`. See [Async tasks](https://docs.querying.ai/concepts/async-tasks.md).

## Actions

| Path | Reads | Required |
| - | - | - |
| `/v1/social/tiktok/search` | Videos for a keyword | `query` |
| `/v1/social/tiktok/video` | One video | `videoId` or `url` |
| `/v1/social/tiktok/comments` | A video's comments and their replies | `videoId` or `url` |
| `/v1/social/tiktok/creator` | A creator's profile | `username` or `url` |
| `/v1/social/tiktok/trending` | Trending videos of a country | none |

For `video` and `comments`, `videoId` and `url` take a video ID, a video or photo post URL, or a `vm.tiktok.com` or `vt.tiktok.com` short link. For `creator`, `username` and `url` take a username, an `@username` or a profile URL, such as `https://www.tiktok.com/@nasa`.

## Parameters

A request with a parameter of another action, a value outside the ones listed below, or a missing required field is refused when you submit it, with `400 VALIDATION_ERROR` naming the field.

`search`:

* `query`: Required, up to 500 characters, with at least one letter or digit.
* `limit`: Optional integer from 1 to 50, default 10. A search finds videos through Google results, so it returns up to `limit` videos, fewer when Google lists fewer. It returns one page.

`comments`:

* `limit`: Optional integer from 1 to 500, default 50. It counts comments and replies together.
* `includeReplies`: `true` (default) reads each comment's replies after it. `false` returns top-level comments only.

`trending`:

* `limit`: Optional integer from 1 to 50, default 20.
* `regionCode`: A two-letter country code, default `US`.

## Response example

```json theme={"theme":"css-variables"}
{
  "platform": "tiktok",
  "action": "search",
  "query": "coffee recipe",
  "videos": [
    {
      "url": "https://www.tiktok.com/@starbucks/video/7689165576589069582",
      "music": {
        "id": "7689165597564750605",
        "title": "original sound - Starbucks",
        "author": "Starbucks",
        "original": true,
        "durationSeconds": 7
      },
      "author": {
        "id": "6717391402571039749",
        "handle": "starbucks",
        "verified": true,
        "profileUrl": "https://www.tiktok.com/@starbucks",
        "displayName": "Starbucks",
        "followerCount": 3600000
      },
      "region": "US",
      "source": "web",
      "caption": "same fresh cup of coffee, different day",
      "videoId": "7689165576589069582",
      "language": "en",
      "position": 1,
      "likeCount": 3861,
      "viewCount": 551300,
      "shareCount": 86,
      "publishedAt": "2026-09-24T18:09:35.000Z",
      "collectCount": 234,
      "commentCount": 87,
      "durationSeconds": 7
    }
  ],
  "hasMore": false,
  "provider": "tiktok_web",
  "nextCursor": null,
  "returnedCount": 1
}
```

## Result fields

* Every response echoes `platform` and `action`, and `provider` names the source the data was read from. Lists carry `returnedCount`.
* A video has `videoId`, `url`, `caption`, `hashtags` (when the caption has any), `author` (`id`, `handle`, `displayName`, `verified`, `avatarUrl`, `profileUrl`, `followerCount`), `music` (`id`, `title`, `author`, `original`, `durationSeconds`), `coverUrl`, `durationSeconds`, `language`, `region`, `publishedAt`, `viewCount`, `likeCount`, `commentCount`, `shareCount` and `collectCount`, the times it was saved. Counts above 1 million are the rounded values TikTok shows.
* `search` returns `videos`, each with its `position` and `source`, and `hasMore` is `false` with `nextCursor` `null`. A result whose page could not be read carries only `url`, `videoId` and the author's `handle` and `profileUrl`.
* `video` returns the video's fields at the top level.
* `comments` returns `videoId`, `url` (`null` when you sent only `videoId`), `comments`, `includeReplies`, `returnedCount`, `topLevelCount`, `replyCount` and `availableTopLevelCount`, the comment count TikTok shows for the video.
  * A comment has `commentId`, `videoId`, `text`, `author`, `likeCount`, `replyCount`, `publishedAt` and `parentId`, which is `null` for a top-level comment and the `commentId` it answers for a reply.
  * A video with no comments, or with comments turned off, ends the task with `ENGINE_NO_RESULT`.
* `creator` returns `creatorId`, `handle`, `displayName`, `bio`, `bioLink`, `avatarUrl`, `profileUrl`, `verified`, `privateAccount`, `createdAt`, `followerCount`, `followingCount`, `likeCount` and `videoCount`.
* `trending` returns `videos` and the `regionCode` it read.
* A video or creator that does not exist or is private ends the task with `PAGE_UNAVAILABLE`. Only completed requests are charged.

## HTML page

Set `include.html` to `true` and the result gains `html`, a link to the TikTok page the answer was read from, saved as a file you can put in a report. `html` has `status`, `url` and `expiresAt`, described in [HTML pages](https://docs.querying.ai/engines/html-pages.md).

* `include.html` works on `video` and `creator`.
* The file is the HTML document TikTok sent for the page, before any script ran. It starts with a note comment, `Saved by querying.ai: the page TikTok served for task <id> at <UTC time>, the page as TikTok sent it, before any script ran, the address of the visit and its session ids masked.`
* Values that belong to the visit are replaced with zeros of the same length: cookie values, session, request and device ids, CSRF and other tokens, nonces and the signatures in media addresses. Because those signatures are masked, the image and video links in the file do not load. Content that depends on where the visit came from, such as the regional CDN host names in media addresses, stays as TikTok sent it.
* The document's scripts are kept as text. The file is served with a Content-Security-Policy that runs no script and loads no outside resource.
* TikTok sends its data inside an embedded JSON script, so the opened file shows almost nothing and the data is in the document source.
* On `video`, a short link is kept as the page it redirects to.
* Every other action (`search`, `comments` and `trending`) returns `422 EVIDENCE_UNSUPPORTED` when you submit the task, and the message names why.
* The page costs nothing extra: the request is still 0.5 credits.
* When the page cannot be kept, the answer is still returned and `html` is `{ "status": "failed", "error": "EVIDENCE_FAILED" }`. Resubmit the task to try again.

## Related

* [Instagram](https://docs.querying.ai/engines/instagram.md)
* [YouTube](https://docs.querying.ai/engines/youtube.md)
* [TikTok Ads](https://docs.querying.ai/engines/tiktok-ads.md), for the ads an advertiser runs on TikTok
* [Engine overview](https://docs.querying.ai/engines/overview.md)
* [Credits and limits](https://docs.querying.ai/concepts/credits-and-limits.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.