YouTube Transcripts API

GET   /api/v1/search?engine=youtube_transcripts

YouTube Transcripts API allows you to get the transcript/subtitles for a given YouTube video.

API Parameters

Search Query

  • Name
    video_id
    Required
    Required
    Description

    Parameter defines the video_id you want to search. You can find these values in JSON responses in YouTube engine or in YouTube page that appears in URL: https://www.youtube.com/watch?v=video_id.

Localization

  • Name
    lang
    Required
    Optional
    Description

    The parameter en sets the default language for transcripts. While a variety of languages are supported, often only a few are available. Review the list of known supported YouTube Transcript languages.

Filters

  • Name
    transcript_type
    Required
    Optional
    Description

    Defines the transcript preference when both auto-generated and manually uploaded transcripts are available.

    • auto - Prioritizes YouTube's auto-generated transcript. It can be translated into any lang language, but retrieval may be slower compared to manual transcripts.
    • manual - Prioritizes manually uploaded transcripts.

Engine

  • Name
    engine
    Required
    Required
    Description

    Parameter defines an engine that will be used to retrieve real-time data. Current engine - youtube_transcripts.

API key

  • Name
    api_key
    Required
    Required
    Description

    The api_key authenticates your requests. Use it as a query parameter (https://www.searchapi.io/api/v1/search?api_key=YOUR_API_KEY) or in the Authorization header (Bearer YOUR_API_KEY).

Zero Data Retention

  • Name
    zero_retention
    Enterprise Only
    Enterprise Only
    Required
    Optional
    Description

    Set this parameter to true to disable all logging and persistent storage. No request parameters, HTML, or JSON responses are stored or logged. Suitable for high-compliance use cases. Debugging and support may be limited while enabled.

API Examples

Full Response

Full Response
GET
https://www.searchapi.org/api/v1/search?engine=youtube_transcripts&video_id=0e3GPea1Tyg
Request
import requests

url = "https://www.searchapi.org/api/v1/search"
params = {
  "engine": "youtube_transcripts",
  "video_id": "0e3GPea1Tyg"
}

response = requests.get(url, params=params)
print(response.text)
Response
{
  "search_metadata": {
    "id": "search_xRvzEGkNolVqF6MLpj4Q9WJb",
    "status": "Success",
    "created_at": "2023-09-15T13:59:31Z",
    "request_time_taken": 1.79,
    "parsing_time_taken": 0.01,
    "total_time_taken": 1.8,
    "request_url": "https://www.youtube.com/watch?v=0e3GPea1Tyg",
    "html_url": "https://www.searchapi.io/api/v1/searches/search_xRvzEGkNolVqF6MLpj4Q9WJb.html",
    "json_url": "https://www.searchapi.io/api/v1/searches/search_xRvzEGkNolVqF6MLpj4Q9WJb"
  },
  "search_parameters": {
    "engine": "youtube_transcripts",
    "video_id": "0e3GPea1Tyg",
    "lang": "en"
  },
  "transcripts": [
    {
      "text": "- [Mr. Beast] I've recreated every single set",
      "start": 0.15,
      "duration": 1.773
    },
    {
      "text": "from Squid Game in real life,",
      "start": 1.923,
      "duration": 1.857
    },
    ...
  ],
  "available_languages": [
    {
      "name": "Arabic",
      "lang": "ar"
    },
    {
      "name": "English",
      "lang": "en"
    },
    ...
  ],
}

Transcripts Available in Other Languages

If the selected language is not available, the API will return available_languages with the list of options. You can then retry and use the language parameter to get the transcript in the desired language.

GET
https://www.searchapi.org/api/v1/search?engine=youtube_transcripts&lang=hi&video_id=MVYrJJNdrEg
Request
import requests

url = "https://www.searchapi.org/api/v1/search"
params = {
  "engine": "youtube_transcripts",
  "video_id": "MVYrJJNdrEg",
  "lang": "hi"
}

response = requests.get(url, params=params)
print(response.text)
Response
{
  ...,
  "search_parameters": {
    "engine": "youtube_transcripts",
    "video_id": "MVYrJJNdrEg",
    "lang": "hi"
  },
  "available_languages": [
    {
      "name": "English (auto-generated)",
      "lang": "en"
    },
    {
      "name": "English (United States)",
      "lang": "en-US"
    }
  ],
  "error": "Selected language hasn't been transcribed. Check `available_languages`."
}