Developer Guide Updated 2026-11-28

How to Get a TikTok Transcript via API (With Code)

Step-by-step developer guide on how to get a TikTok transcript via API using cURL, Python, Node.js, and MCP, including Whisper fallback for uncaptioned clips.

Learning how to get a TikTok transcript via API is one of the highest-leverage upgrades you can make to a content research script or AI agent pipeline. Instead of downloading multi-megabyte MP4 files, stripping audio with ffmpeg, and running local speech recognition models, a single HTTPS POST request returns clean, timestamped spoken dialogue in structured JSON.

Want to inspect the response payload right now before writing code? Try our interactive TikTok Transcript API tester or claim 100 free credits (no credit card required) to run live calls immediately.

Why raw TikTok scraping fails on uncaptioned videos

Developers who build DIY TikTok caption scrapers with yt-dlp, Playwright, or undocumented web endpoints usually run into three production blockers within days:

  1. Missing native subtitle tracks: Between 30% and 40% of viral TikTok videos—especially raw creator vlogs, street interviews, and comedy skits—do not carry an embedded WebVTT/SRT closed-caption track. Caption-only scrapers return null on those videos.
  2. Signed URL expiration & IP blocks: TikTok's web player binds subtitle and media URLs to short-lived X-Bogus / _signature tokens and datacenter IP rate limits, causing headless jobs on AWS or Cloudflare Workers to fail with empty responses.
  3. Inconsistent segment formatting: Creator-uploaded captions, auto-generated TikTok ASR captions, and multi-language translation tracks use different JSON/WebVTT structures that break downstream LLM prompts.

Our TikTok Transcript API solves all three problems behind one endpoint: it extracts native caption tracks in under two seconds when available, and automatically falls back to server-side Whisper speech-to-text on the original audio track whenever captions are missing.

Step 1: Get your API key and 100 free credits

  1. Sign in with Google or email OTP at https://socialtoai.app/sign-in/ to receive 100 free credits automatically.
  2. Open Console → API Keys and generate a bearer key (stai_live_...). You can optionally set a daily_limit_credits cap on the key so automated scripts stay strictly within budget.
  3. Every TikTok transcript request costs 2 to 4 credits on success, and 0 credits if the video is deleted, private, or unreachable.

Step 2: Fetch a TikTok transcript with cURL

Pass any public TikTok share URL (vm.tiktok.com/...), desktop video URL (tiktok.com/@handle/video/...), or numeric aweme_id to POST https://socialtoai.app/v1/call with "capability": "tiktok.transcript":

curl -sS -X POST "https://socialtoai.app/v1/call" \
  -H "Authorization: Bearer stai_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "capability": "tiktok.transcript",
    "url": "https://www.tiktok.com/@creator/video/743928192038471",
    "idempotency_key": "tk-transcript-743928192038471"
  }'

Example JSON response

Whether the video used native closed captions or automatic Whisper speech recognition, the response follows a predictable envelope:

{
  "request_id": "req_9f82c104a8b2",
  "envelope_status": "ok",
  "platform": "tiktok",
  "capability": "tiktok.transcript",
  "billing": {
    "credits": 2,
    "failed_call_charge": 0,
    "balance_credits": 98
  },
  "data": {
    "aweme_id": "743928192038471",
    "language": "en",
    "source": "native_cc",
    "full_text": "Most developers waste two weeks maintaining residential proxies for TikTok. Here is how to pull clean transcripts and top comments in ten lines of Python.",
    "segments": [
      {
        "start": "00:00.00",
        "end": "00:04.20",
        "text": "Most developers waste two weeks maintaining residential proxies for TikTok."
      },
      {
        "start": "00:04.20",
        "end": "00:09.10",
        "text": "Here is how to pull clean transcripts and top comments in ten lines of Python."
      }
    ]
  }
}

Step 3: Python example — Transcribe + pull top comments

In real viral-hook analysis, combining the spoken script with top audience comments gives your LLM both the creator's pitch and viewer reactions. Here is a complete Python script using requests with idempotency protection:

import os
import requests

API_KEY = os.environ["SOCIAL_AGENT_API_KEY"]
BASE_URL = "https://socialtoai.app/v1"
HEADERS = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json",
}

def analyze_tiktok_video(video_url: str) -> dict:
    # 1. Fetch timestamped spoken transcript (native CC or Whisper fallback)
    tr_resp = requests.post(
        f"{BASE_URL}/call",
        headers=HEADERS,
        json={
            "capability": "tiktok.transcript",
            "url": video_url,
        },
        timeout=45,
    )
    tr_resp.raise_for_status()
    transcript_payload = tr_resp.json()

    # 2. Fetch top 20 comments for audience sentiment
    cm_resp = requests.post(
        f"{BASE_URL}/comments",
        headers=HEADERS,
        json={
            "platform": "tiktok",
            "url": video_url,
            "limit": 20,
        },
        timeout=30,
    )
    cm_resp.raise_for_status()
    comments_payload = cm_resp.json()

    return {
        "transcript": transcript_payload.get("data", {}),
        "comments": comments_payload.get("items", []),
    }

if __name__ == "__main__":
    result = analyze_tiktok_video("https://www.tiktok.com/@creator/video/743928192038471")
    print("Full Script:", result["transcript"].get("full_text"))
    print("Top Comments Fetched:", len(result["comments"]))

Step 4: Node.js / TypeScript batch extraction with concurrency control

When transcribing 50 videos from a creator profile or keyword search, use Node 20+ native fetch with a small concurrency pool (3 to 5 concurrent requests) and check envelope_status:

const API_KEY = process.env.SOCIAL_AGENT_API_KEY;

export async function getTikTokTranscript(videoUrl) {
  const res = await fetch("https://socialtoai.app/v1/call", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      capability: "tiktok.transcript",
      url: videoUrl,
    }),
  });

  if (!res.ok) {
    throw new Error(`HTTP ${res.status}: ${await res.text()}`);
  }

  const body = await res.json();
  if (body.envelope_status !== "ok") {
    // Failed or empty calls automatically charge 0 credits
    return null;
  }
  return body.data;
}

Step 5: Zero-code option via MCP in Claude, Cursor, and Antigravity

If you are researching viral hooks interactively inside an AI coding editor or chat client rather than running a backend cron job, you do not need to write any HTTP code at all. Mount our social media MCP server (https://socialtoai.app/mcp) in Google Antigravity, Claude Desktop, Claude Code, or Cursor, and simply prompt:

  • "Search TikTok for the top 10 videos about 'AI note taking app', fetch transcripts for the top 3 by view count, and break down their first-3-second verbal hooks."

Production best practices and error handling

  1. Always pass idempotency_key on automated retries: Using a deterministic key such as tk-tr-${awemeId} guarantees that retrying a network timeout never deducts credits twice.
  2. Allow a 45-second HTTP timeout for Whisper fallback: Native subtitle extraction finishes in 1 to 2 seconds, while uncaptioned videos that trigger Whisper audio transcription typically take 6 to 18 seconds depending on video duration.
  3. Combine organic and paid creative scripts: Cross-check organic viral scripts from the TikTok Transcript API against paid ad hooks using our Meta Ad Library API or Chinese short-video trends on the Xiaohongshu MCP Server.

Ready to run your first batch? Open the interactive TikTok Transcript API page or review prepaid credit packs ($10 = 3,000 credits) on our pricing page.

Frequently asked questions about TikTok transcript API code integration

What is the fastest way to get a TikTok transcript via API in Python or Node.js?

Send an authenticated POST request to https://socialtoai.app/v1/call with capability "tiktok.transcript" and the public TikTok URL. You receive JSON containing full_text, detected language, and timestamped segments.

What HTTP timeout should I set when calling the TikTok transcript endpoint?

Native caption extraction usually completes in 1 to 2 seconds. When a video has no native captions and triggers automatic Whisper speech-to-text fallback, set your client timeout to 45 seconds.

Am I charged credits if a TikTok video URL is private or deleted?

No. If a video was deleted, set to private, or fails upstream extraction, envelope_status reflects the failure and 0 credits are deducted from your balance.