How to Get a TikTok Transcript via API & MCP (cURL, Python & TypeScript)
https://socialtoai.app/mcp · Try in PlaygroundExtracting spoken words from TikTok videos is the fastest way to study viral 3-second hooks, summarize product reviews, or feed short-form video trends into an AI agent. Yet TikTok's official Display API does not expose arbitrary public video transcripts, and maintaining headless browser scrapers breaks every time web signatures rotate. Here is how to pull clean JSON transcripts and timestamps in one HTTP request using the SocialToAI TikTok Transcript API.
How the TikTok transcript endpoint works
In SocialToAI, TikTok transcripts are returned through the unified POST https://socialtoai.app/v1/detail endpoint by setting "platform": "tiktok" and "include": "transcript":
- Input: Either a public video
id(e.g."7665840565958872333") or fullurl. - Output: Post metadata (author, view/like/comment/share counts, publish timestamp) plus
text(full transcript string) andsegments(array of{ start, end, text }). - Price: 2 credits per video ($0.0067 starter / $0.004 volume). Failed calls cost 0 credits.
1. Quick test with cURL
Grab an API key from your console (new accounts start with 100 free credits, no card needed) and send one POST request:
curl -X POST "https://socialtoai.app/v1/detail" \
-H "Authorization: Bearer $SOCIALTOAI_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"platform": "tiktok",
"url": "https://www.tiktok.com/@creator/video/7665840565958872333",
"include": "transcript"
}'
Every response includes a request_id, billing.credits, and a 24-hour handle (res_...) you can re-fetch for free via GET /v1/results/{handle}.
2. Python script: parse full text & timed hook segments
This Python helper fetches a video's transcript and isolates what the creator said in the opening 5 seconds—ideal for ad-creative and meme-hook analysis:
import os
import uuid
import requests
API_KEY = os.environ["SOCIALTOAI_API_KEY"]
def get_tiktok_transcript(video_url: str) -> dict:
resp = requests.post(
"https://socialtoai.app/v1/detail",
headers={
"Authorization": f"Bearer {API_KEY}",
"Idempotency-Key": str(uuid.uuid4()),
"Content-Type": "application/json",
},
json={
"platform": "tiktok",
"url": video_url,
"include": "transcript",
},
timeout=30,
)
resp.raise_for_status()
payload = resp.json()
item = (payload.get("items") or [{}])[0]
segments = item.get("segments") or []
opening_hook = " ".join(
seg.get("text", "") for seg in segments if float(seg.get("start", 0)) <= 5.0
)
return {
"id": item.get("id"),
"views": item.get("views"),
"likes": item.get("likes"),
"opening_5s_hook": opening_hook,
"full_transcript": item.get("text", ""),
"segment_count": len(segments),
"credits_used": payload.get("billing", {}).get("credits", 0),
}
if __name__ == "__main__":
result = get_tiktok_transcript("https://www.tiktok.com/@tiktok/video/7665840565958872333")
print("5s Hook:", result["opening_5s_hook"])
print("Full Text:", result["full_transcript"][:300])
3. TypeScript / Node.js: discover a creator's top videos & transcribe them
Want to transcribe a competitor's 10 best-performing TikTok posts automatically? Chain POST /v1/user_posts (2 credits) with POST /v1/detail (include: "transcript", 2 credits each):
import crypto from "node:crypto";
const API_KEY = process.env.SOCIALTOAI_API_KEY!;
const BASE = "https://socialtoai.app";
async function callApi(path: string, body: Record<string, unknown>) {
const res = await fetch(`${BASE}${path}`, {
method: "POST",
headers: {
Authorization: `Bearer ${API_KEY}`,
"Idempotency-Key": crypto.randomUUID(),
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
return res.json();
}
export async function transcribeTopCreatorPosts(username: string, topN = 5) {
const postsRes = await callApi("/v1/user_posts", { platform: "tiktok", username });
const sorted = (postsRes.items ?? [])
.sort((a: any, b: any) => (b.views ?? 0) - (a.views ?? 0))
.slice(0, topN);
const transcripts = [];
for (const post of sorted) {
const detail = await callApi("/v1/detail", {
platform: "tiktok",
id: String(post.id),
include: "transcript",
});
const item = detail.items?.[0] ?? {};
transcripts.push({
id: post.id,
views: post.views,
transcript: item.text ?? "",
});
}
return transcripts;
}
Total cost for listing a creator's recent videos plus transcribing the top 5 outliers: 2 + (5 × 2) = 12 credits (roughly $0.04).
Handling TikTok videos without native captions
What happens when a TikTok video has spoken dialogue in the audio track, or on-screen text, but no native caption file? Use a two-tier fallback:
- Check
include: "transcript"first (2 credits): Covers the vast majority of English, Spanish, and multilingual creator videos where TikTok auto-generated speech captions. - Fetch raw media via
POST /v1/call/tiktok.media(2 credits): Returns direct watermark-free MP4 video URLs, extracted MP3/M4A audio URLs, and high-res cover frames—so you can pass silent visual memes to a vision model or run custom ASR on niche dialects.
Zero-code option: let Claude, ChatGPT or Cursor call it over MCP
If you don't want to write HTTP boilerplate at all, connect https://socialtoai.app/mcp in Claude Code, Cursor, or Antigravity and ask in plain English:
"Pull the last 10 videos from @duolingo on TikTok, get the transcript and top comments for the 3 highest-view videos, and summarize the hook patterns."
Ready to test? See the full TikTok Transcript API reference or run a live call in the Playground.
FAQ
Can I pass a full TikTok share URL or just the numeric video ID?
Either works. Pass "url": "https://www.tiktok.com/@user/video/7665840565958872333" or "id": "7665840565958872333" with "include": "transcript" to POST /v1/detail.
How much does extracting 500 TikTok transcripts cost?
At 2 credits per video, 500 videos use 1,000 credits—about $3.33 on the $10 starter pack (3,000 credits), or $2.00 on volume packs. Your first 50 videos are completely free with the 100 sign-up credits.
Why is Idempotency-Key required on POST /v1/detail?
Idempotency-Key protects your balance during network retries: if your script times out and retries with the same UUID within 24 hours, SocialToAI replays the cached result without charging a second time.
Published: Last updated: