> ## Documentation Index
> Fetch the complete documentation index at: https://docs.llmlayer.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# YouTube Transcript API - Extract video transcripts

> Extract transcripts from YouTube videos with optional language selection. Returns transcript plus video metadata (title, author, views, likes, date).



## OpenAPI

````yaml post /api/v2/youtube_transcript
openapi: 3.0.0
info:
  title: LLMLayer API
  version: 2.0.0
  description: >-
    The Web API for AI Agents - Search, scrape, extract content, crawl websites,
    and generate AI-powered answers with multiple LLMs
servers:
  - url: https://api.llmlayer.dev
security: []
tags:
  - name: Answer API
    description: >-
      Web-enhanced AI responses combining search with multiple LLM models.
      Supports streaming, custom prompts, and structured JSON output.
  - name: Web Search
    description: >-
      Direct web search across multiple content types (general, news, shopping,
      videos, images, scholar) without AI processing.
  - name: Content Extraction
    description: >-
      Extract content from websites, PDFs, and YouTube videos in multiple
      formats.
  - name: Web Crawling
    description: >-
      Map websites and crawl multiple pages with depth control. Supports
      streaming with markdown output.
paths:
  /api/v2/youtube_transcript:
    post:
      tags:
        - Content Extraction
      summary: YouTube Transcript API - Extract video transcripts
      description: >-
        Extract transcripts from YouTube videos with optional language
        selection. Returns transcript plus video metadata (title, author, views,
        likes, date).
      operationId: getYoutubeTranscript
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/YTRequest'
      responses:
        '200':
          description: Extracted transcript with video metadata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/YTResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - BearerAuth: []
components:
  schemas:
    YTRequest:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
          description: YouTube video URL (supports youtube.com and youtu.be)
          example: https://www.youtube.com/watch?v=dQw4w9WgXcQ
        language:
          type: string
          nullable: true
          description: >-
            Language code for transcript (e.g., 'en', 'es', 'fr'). If not
            specified, uses video's default language.
          example: en
    YTResponse:
      type: object
      required:
        - transcript
        - url
      properties:
        transcript:
          type: string
          description: Full video transcript text
        url:
          type: string
          description: YouTube video URL
        title:
          type: string
          nullable: true
          description: Video title
        description:
          type: string
          nullable: true
          description: Video description
        author:
          type: string
          nullable: true
          description: Channel name/author
        views:
          type: integer
          nullable: true
          description: View count
        likes:
          type: integer
          nullable: true
          description: Like count
        date:
          type: string
          nullable: true
          description: Upload date
        cost:
          type: number
          nullable: true
          description: Cost in USD (value from COST_YOUTUBE_TRANSCRIPT constant)
        language:
          type: string
          nullable: true
          description: Language of the returned transcript
    ErrorResponse:
      type: object
      required:
        - detail
      properties:
        detail:
          type: object
          required:
            - error_type
            - error_code
            - message
          properties:
            error_type:
              type: string
              enum:
                - validation_error
                - authentication_error
                - provider_error
                - rate_limit
                - internal_error
                - scraping_error
                - search_error
                - map_error
              description: Category of error
            error_code:
              type: string
              description: Specific error code for programmatic handling
              example: missing_query
            message:
              type: string
              description: Human-readable error message
            details:
              type: object
              additionalProperties: true
              nullable: true
              description: Additional error context and debugging information
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            missing_query:
              value:
                detail:
                  error_type: validation_error
                  error_code: missing_query
                  message: Query parameter cannot be empty
            missing_json_schema:
              value:
                detail:
                  error_type: validation_error
                  error_code: missing_json_schema
                  message: JSON schema is required for JSON response type
            invalid_max_pages:
              value:
                detail:
                  error_type: validation_error
                  error_code: invalid_max_pages
                  message: max_pages must be between 1 and 100
    Unauthorized:
      description: Authentication error - missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            detail:
              error_type: authentication_error
              error_code: missing_llmlayer_api_key
              message: 'Provide LLMLayer API key via ''Authorization: Bearer <token>'''
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            unexpected_error:
              value:
                detail:
                  error_type: internal_error
                  error_code: unexpected_error
                  message: An unexpected error occurred. Please try again later
            scraping_error:
              value:
                detail:
                  error_type: scraping_error
                  error_code: url_scrape_failed
                  message: Failed to scrape content from the provided URL
                  details:
                    url: https://www.ycombinator.com
                    error: Connection timeout
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer token authentication using your LLMLayer API key. Include in
        Authorization header as: Bearer YOUR_LLMLAYER_API_KEY

````