TEST SITE: not indexed, not the live website. Placeholder button URLs in use: signup, login, dashboard, playground, api_base.
Docs menu

Python guide

requests example.

  • 2 min read
  • Last verified
Draft notice

Owner check needed: endpoint, parameter, limit and error names here come from the planning spec, not from the live service. Confirm them against the real API before launch.

Overview

A short Python client: one function, a timeout, typed errors and a retry for retryable failures.

  • requests, a timeout, typed errors.
  • Retry only retryable errors.
quickstart.py
import os, requests

API = os.environ.get("TTA_API_BASE", "https://api.example.com")
r = requests.get(
    f"{API}/api/v1/tiktok/transcript",
    params={"url": "https://www.tiktok.com/@gardenclub/video/7000000000000000001", "lang": "en"},
    headers={"Authorization": f"Bearer {os.environ['TTA_API_KEY']}"},
    timeout=60,
)
data = r.json()
if not data["success"]:
    raise SystemExit(f"{data['error']['code']}: {data['error']['message']}")
print(data["transcript_source"], data["language_code"], len(data["segments"]), "segments")
print(data["transcript"])
print("credits left:", data["credits_remaining"])

A minimal call

Captured output from the local mock (not the real API)
captions en 5 segments
Okay, three tips for a small garden. Tip one: measure the sun before you buy seeds. Tip two: raised beds drain better. Tip three: water in the morning. Follow for the full guide.
credits left: 14999

Handle errors

Check success before you read fields, and use error.retryable to decide whether to try again. The batch workflow has a full loop with backoff and Retry-After.

Error from the mock for a private video
error private_video: This video is private.

Set a timeout

Always pass timeout. Speech-to-text can take a while, so use the job flow rather than a very long timeout.

Next: fetch many transcripts and async jobs. Run against the local mock in tools/mock-api, which follows the assumed contract on these pages. It is not the real API, and the output is captured from that mock.

Ready to call it from your code?

Get API key
Get API keyDocs