YTAPI.devDocs

Extract transcript

extractTranscript(params, options?): TranscriptResponse

POST
https://api.ytapi.dev/v1/transcripts
1 Credit

This is the primary transcript endpoint. Submit a JSON body with the video id and optional format, language, and track policy. GET /v1/transcripts runs the same extractor with query parameters.

Successful requests consume 1 credit. Missing captions return 404 and are not billed.

API Key

All requests require a valid API key from the developer dashboard.

Headers: Authorization: Bearer YOUR_API_KEYorX-API-Key: YOUR_API_KEY

See Authentication for headers and rate limits.

Request Body

ParameterTypeRequiredDescription
video_idbody
stringYes

11-character YouTube video ID or a full video URL.

formatbody
stringNo

Output format: segments (default), word_timestamps, sentences, markdown, text, srt, vtt, or json3.

word_levelbody
booleanNo

Include millisecond word offsets. Only auto-generated (ASR) captions carry word timing; creator captions never do. With the default track_policy=manual_first, a video that has creator captions returns those, so pass track_policy=asr_first when you need words. Some auto-generated tracks have no word timing either; has_word_level tells you. Default false.

languagesbody
string[]No

Prioritized ISO language codes, for example ["en", "es"]. "*" means the video's own language: the language spoken in it (its auto-generated track), or its only track when there is none. Default ["*"]. For English when the video has it and its own language otherwise, pass ["en", "*"]. The response language field says which track was returned.

track_policybody
stringNo

Track selection: manual_first (default) prefers creator captions and falls back to auto-generated; asr_first prefers auto-generated and falls back to creator captions; exact_only accepts only a track whose language code matches exactly (en does not match en-GB), creator captions first. Any other value returns 400 invalid_request. Languages are tried in order first, then track kind within the matched language: if the English track is auto-generated only, ["en", "*"] returns it rather than moving on. To see which languages and kinds a video has before spending a credit, call the free basic info endpoint: each entry in available_languages has kind manual or asr. The response track_kind says which one you got.

Response (HTTP 200)

When format=word_timestamps, segments, sentences, or json3 (application/json):

{
  "video_id": string,            // Echoed YouTube video ID
  "language": string,            // Negotiated ISO language code (e.g. "en")
  "track_kind": string,          // "asr" (auto-generated) or "manual" (creator-uploaded)
  "duration_seconds": number,    // Total duration of caption track in seconds
  "has_word_level": boolean,     // Whether genuine word-level timing precision is present
  "segments": [                  // Array of caption segments
    {
      "text": string,            // Segment transcript text
      "start": number,           // Start offset in seconds
      "end": number,             // End offset in seconds
      "duration": number,        // Segment duration in seconds
      "words": [                 // Word-level timestamps (populated when word_level=true)
        {
          "word": string,        // Individual word
          "start": number,       // Word start offset
          "end": number          // Word end offset
        }
      ]
    }
  ]
}

When format=markdown, text, srt, or vtt:

Returns the raw document directly with matching Content-Type (e.g. text/markdown, text/plain, text/vtt) without JSON wrapper overhead.