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

> TikTok 영상을 검색하고 영상, 답글을 포함한 댓글, 크리에이터, 트렌딩 영상을 JSON으로 읽습니다. 조회수, 좋아요, 공유, 저장, 댓글 수와 게시 시각을 함께 받습니다.

공개 TikTok 데이터를 `POST /v1/social/tiktok/{action}`로 JSON으로 읽습니다. `{action}`으로 읽을 대상을 고릅니다. 완료된 요청당 **0.5크레딧**입니다.

## 요청

```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 }'
```

요청은 결과가 나올 때까지 최대 290초 기다렸다가 `200`으로 응답하며, 결과는 `response`에 담깁니다. 그때까지 끝나지 않은 task는 `202`로 응답하므로 `GET /v1/async/task/{id}`를 폴링하거나 `webhook`을 설정합니다. 참고: [비동기 task](https://docs.querying.ai/ko/concepts/async-tasks.md).

## 동작

| 경로 | 읽는 대상 | 필수 |
| - | - | - |
| `/v1/social/tiktok/search` | 키워드로 찾은 영상 | `query` |
| `/v1/social/tiktok/video` | 영상 하나 | `videoId` 또는 `url` |
| `/v1/social/tiktok/comments` | 영상의 댓글과 답글 | `videoId` 또는 `url` |
| `/v1/social/tiktok/creator` | 크리에이터 프로필 | `username` 또는 `url` |
| `/v1/social/tiktok/trending` | 국가별 트렌딩 영상 | 없음 |

`video`와 `comments`에서 `videoId`와 `url`은 영상 ID, 영상이나 사진 게시물 URL, `vm.tiktok.com`이나 `vt.tiktok.com` 단축 링크를 받습니다. `creator`에서 `username`과 `url`은 사용자 이름, `@username`, `https://www.tiktok.com/@nasa` 같은 프로필 URL을 받습니다.

## 입력

다른 동작의 파라미터나 아래에 없는 값이 있거나 필수 필드가 빠진 요청은 제출할 때 해당 필드를 밝힌 `400 VALIDATION_ERROR`로 거절됩니다.

`search`:

* `query`: 필수이며 최대 500자이고 글자나 숫자가 하나 이상 있어야 합니다.
* `limit`: 선택. 1-50 정수이며 기본값은 10입니다. 검색은 Google 결과로 영상을 찾으므로 최대 `limit`개를 돌려주며, Google이 적게 나열하면 더 적게 돌려줍니다. 한 페이지로 답합니다.

`comments`:

* `limit`: 선택. 1-500 정수이며 기본값은 50입니다. 댓글과 답글을 합산한 개수입니다.
* `includeReplies`: `true`(기본값)이면 각 댓글 뒤에 그 답글을 읽습니다. `false`이면 최상위 댓글만 돌려줍니다.

`trending`:

* `limit`: 선택. 1-50 정수이며 기본값은 20입니다.
* `regionCode`: 두 글자 국가 코드이며 기본값은 `US`입니다.

## 응답 예시

```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
}
```

## 결과 필드

* 모든 응답은 `platform`과 `action`을 그대로 돌려주고, `provider`는 데이터를 읽은 출처를 나타냅니다. 목록에는 `returnedCount`가 있습니다.
* 영상에는 `videoId`, `url`, `caption`, `hashtags`(캡션에 있을 때), `author`(`id`, `handle`, `displayName`, `verified`, `avatarUrl`, `profileUrl`, `followerCount`), `music`(`id`, `title`, `author`, `original`, `durationSeconds`), `coverUrl`, `durationSeconds`, `language`, `region`, `publishedAt`, `viewCount`, `likeCount`, `commentCount`, `shareCount`, 영상이 저장된 횟수인 `collectCount`가 있습니다. 100만이 넘는 수는 TikTok이 보여 주는 반올림된 값입니다.
* `search`는 `videos`를 돌려주며 각 영상에 `position`과 `source`가 붙습니다. `hasMore`는 `false`이고 `nextCursor`는 `null`입니다. 페이지를 읽지 못한 결과에는 `url`, `videoId`와 작성자의 `handle`, `profileUrl`만 있습니다.
* `video`는 영상의 필드를 최상위에 돌려줍니다.
* `comments`는 `videoId`, `url`(`videoId`만 보냈다면 `null`), `comments`, `includeReplies`, `returnedCount`, `topLevelCount`, `replyCount`, TikTok이 영상에 보여 주는 댓글 수인 `availableTopLevelCount`를 돌려줍니다.
  * 댓글에는 `commentId`, `videoId`, `text`, `author`, `likeCount`, `replyCount`, `publishedAt`, `parentId`가 있습니다. 이 값은 최상위 댓글이면 `null`이고 답글이면 그 답글이 달린 댓글의 `commentId`입니다.
  * 댓글이 없거나 댓글을 끈 영상은 task를 `ENGINE_NO_RESULT`로 끝냅니다.
* `creator`는 `creatorId`, `handle`, `displayName`, `bio`, `bioLink`, `avatarUrl`, `profileUrl`, `verified`, `privateAccount`, `createdAt`, `followerCount`, `followingCount`, `likeCount`, `videoCount`를 돌려줍니다.
* `trending`은 `videos`와 읽은 `regionCode`를 돌려줍니다.
* 없거나 비공개인 영상이나 크리에이터는 task를 `PAGE_UNAVAILABLE`로 끝냅니다. 완료된 요청만 과금합니다.

## HTML 페이지

`include.html`을 `true`로 설정하면 결과에 `html`이 추가됩니다. 답변을 읽은 TikTok 페이지의 링크이며, 보고서에 넣을 수 있는 파일로 저장됩니다. `html`에는 `status`, `url`, `expiresAt`이 있으며 [HTML 페이지](https://docs.querying.ai/ko/engines/html-pages.md)에서 설명합니다.

* `include.html`은 `video`, `creator`에서 동작합니다.
* 파일은 TikTok이 그 페이지에 보낸 HTML 문서이며, 스크립트가 실행되기 전 상태입니다. 맨 앞에 메모 주석이 있습니다. `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.`
* 방문에 속하는 값은 같은 길이의 0으로 바꿉니다. 쿠키 값, 세션·요청·기기 ID, CSRF 등의 토큰, nonce, 미디어 주소의 서명이 해당합니다. 이 서명을 가렸기 때문에 파일 안의 이미지와 동영상 링크는 로드되지 않습니다. 미디어 주소의 지역별 CDN 호스트 이름처럼 방문이 어디서 왔는지에 따라 달라지는 내용은 TikTok이 보낸 그대로 둡니다.
* 문서의 스크립트는 텍스트로 파일에 남습니다. 파일은 스크립트를 실행하지 않고 외부 리소스도 불러오지 않는 Content-Security-Policy와 함께 제공됩니다.
* TikTok은 데이터를 내장된 JSON 스크립트 안에 담아 보내므로 열어 본 파일에는 거의 아무것도 보이지 않고, 데이터는 문서 소스에 있습니다.
* `video`에서는 짧은 링크를 리디렉션되는 페이지로 저장합니다.
* 그 밖의 모든 동작(`search`, `comments`, `trending`)은 태스크를 보낼 때 `422 EVIDENCE_UNSUPPORTED`를 반환하며, 메시지에 이유가 나옵니다.
* 페이지에는 추가 요금이 없습니다. 요청은 그대로 0.5크레딧입니다.
* 페이지를 저장할 수 없어도 답변은 반환되고 `html`은 `{ "status": "failed", "error": "EVIDENCE_FAILED" }`가 됩니다. 다시 받으려면 태스크를 다시 보내세요.

## 관련 문서

* [Instagram](https://docs.querying.ai/ko/engines/instagram.md)
* [YouTube](https://docs.querying.ai/ko/engines/youtube.md)
* [TikTok 광고](https://docs.querying.ai/ko/engines/tiktok-ads.md): 광고주가 TikTok에서 집행하는 광고
* [엔진 목록](https://docs.querying.ai/ko/engines/overview.md)
* [크레딧과 한도](https://docs.querying.ai/ko/concepts/credits-and-limits.md)


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