> ## 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}` で読み取る対象を選びます。完了したリクエスト 1 件につき **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` に入ります。実行中のタスクは `202` で応答するため、`GET /v1/async/task/{id}` をポーリングするか `webhook` を設定します。[非同期タスク](https://docs.querying.ai/ja/concepts/async-tasks.md)を参照してください。

## アクション

| パス | 読み取る内容 | 必須 |
| - | - | - |
| `/v1/social/tiktok/search` | キーワードで探した動画 | `query` |
| `/v1/social/tiktok/video` | 動画 1 件 | `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 文字までです。文字か数字を 1 つ以上含めます。
* `limit`: 任意。1 から 50 の整数で、デフォルトは 10 です。検索は Google の結果から動画を探すため、最大 `limit` 件の動画を返し、Google が挙げる動画が少なければそれより少なくなります。1 ページで返します。

`comments`:

* `limit`: 任意。1 から 500 の整数で、デフォルトは 50 です。コメントと返信を合わせた件数です。
* `includeReplies`: `true` (デフォルト) は各コメントのあとにその返信を読み取ります。`false` は最上位のコメントだけを返します。

`trending`:

* `limit`: 任意。1 から 50 の整数で、デフォルトは 20 です。
* `regionCode`: 2 文字の国コードで、デフォルトは `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` です。
  * コメントがない動画や、コメントをオフにした動画は、タスクを `ENGINE_NO_RESULT` で終了させます。
* `creator` は `creatorId`、`handle`、`displayName`、`bio`、`bioLink`、`avatarUrl`、`profileUrl`、`verified`、`privateAccount`、`createdAt`、`followerCount`、`followingCount`、`likeCount`、`videoCount` を返します。
* `trending` は `videos` と、読み取った `regionCode` を返します。
* 存在しない、または非公開の動画やクリエイターは、タスクを `PAGE_UNAVAILABLE` で終了させます。課金されるのは完了したリクエストだけです。

## HTMLページ

`include.html` を `true` にすると、結果に `html` が加わります。回答の読み取り元である TikTok のページへのリンクで、レポートに載せられるファイルとして保存されます。`html` には `status`、`url`、`expiresAt` があり、[HTMLページ](https://docs.querying.ai/ja/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.`
* 訪問に属する値は同じ長さのゼロに置き換えます。Cookie の値、セッション・リクエスト・デバイスの 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/ja/engines/instagram.md)
* [YouTube](https://docs.querying.ai/ja/engines/youtube.md)
* [TikTok 広告](https://docs.querying.ai/ja/engines/tiktok-ads.md): 広告主が TikTok で配信している広告
* [エンジン一覧](https://docs.querying.ai/ja/engines/overview.md)
* [クレジットと上限](https://docs.querying.ai/ja/concepts/credits-and-limits.md)


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