{
  "openapi": "3.1.0",
  "info": {
    "title": "YouTube Description Extractor API",
    "description": "Public API to extract full video descriptions, titles, channel details, statistics, tags, hashtags, timestamps, and thumbnail download links from public YouTube videos and Shorts.",
    "version": "1.1.0",
    "contact": {
      "name": "YouTube Description Extractor Support",
      "url": "https://ytdescriptionextractorr.com/contact"
    }
  },
  "servers": [
    {
      "url": "https://ytdescriptionextractorr.com",
      "description": "Production server"
    }
  ],
  "paths": {
    "/api/extract": {
      "get": {
        "summary": "Extract YouTube description and metadata via GET",
        "description": "Retrieves the full published description, title, channel information, statistics, tags, hashtags, timestamps, and thumbnails for any public YouTube video or Shorts URL passed as a query parameter.",
        "operationId": "extractYouTubeMetadataGet",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "description": "The public YouTube video URL, Shorts link, or bare 11-character video ID.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful extraction",
            "headers": {
              "Cache-Control": {
                "description": "Caching directives for CDNs and proxies",
                "schema": {
                  "type": "string",
                  "example": "public, s-maxage=300, stale-while-revalidate=60"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtractResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid URL or video ID",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Video not found or private",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "502": {
            "description": "Upstream YouTube API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "YouTube API quota exceeded or unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Extract YouTube description and metadata via POST",
        "description": "Retrieves the full published description, title, channel details, statistics, tags, hashtags, timestamps, and thumbnails for any public YouTube video or Shorts URL.",
        "operationId": "extractYouTubeMetadataPost",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["url"],
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "The public YouTube video URL, Short link, or 11-character video ID."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful extraction",
            "headers": {
              "Cache-Control": {
                "description": "Caching directives for CDNs and proxies",
                "schema": {
                  "type": "string",
                  "example": "public, s-maxage=300, stale-while-revalidate=60"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtractResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid URL or JSON body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Video not found or private",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "502": {
            "description": "Upstream YouTube API error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "YouTube API quota exceeded or unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/thumbnail": {
      "get": {
        "summary": "Download YouTube video thumbnail image",
        "description": "Proxies and streams the thumbnail image for an 11-character YouTube video ID with Content-Disposition attachment headers for direct downloading.",
        "operationId": "downloadYouTubeThumbnail",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "description": "The 11-character YouTube video ID (e.g. dQw4w9WgXcQ).",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{11}$"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Thumbnail quality identifier.",
            "schema": {
              "type": "string",
              "enum": ["maxresdefault", "sddefault", "hqdefault", "mqdefault", "default"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Thumbnail JPEG image stream",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string",
                  "example": "attachment; filename=\"dQw4w9WgXcQ-maxresdefault.jpg\""
                }
              },
              "Content-Type": {
                "schema": {
                  "type": "string",
                  "example": "image/jpeg"
                }
              }
            },
            "content": {
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid video ID or quality parameter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Requested thumbnail quality does not exist for this video",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "502": {
            "description": "Error retrieving thumbnail from YouTube",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ExtractResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": true
          },
          "data": {
            "$ref": "#/components/schemas/ExtractData"
          }
        }
      },
      "ExtractData": {
        "type": "object",
        "properties": {
          "videoId": {
            "type": "string",
            "example": "dQw4w9WgXcQ"
          },
          "channelId": {
            "type": "string",
            "example": "UCuAXFkgsw1L7xaCfnd5JJOw"
          },
          "channelTitle": {
            "type": "string",
            "example": "Rick Astley"
          },
          "publishedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2009-10-25T06:57:33Z"
          },
          "title": {
            "type": "string",
            "example": "Rick Astley - Never Gonna Give You Up (Official Music Video)"
          },
          "description": {
            "type": "string",
            "example": "The official video for 'Never Gonna Give You Up' by Rick Astley..."
          },
          "duration": {
            "type": "string",
            "example": "PT3M33S"
          },
          "durationSeconds": {
            "type": "integer",
            "example": 213
          },
          "durationText": {
            "type": "string",
            "example": "3:33"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": ["Rick Astley", "Never Gonna Give You Up", "Pop"]
          },
          "hashtags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": ["#RickAstley", "#NeverGonnaGiveYouUp"]
          },
          "viewCount": {
            "type": "integer",
            "nullable": true,
            "example": 1500000000
          },
          "likeCount": {
            "type": "integer",
            "nullable": true,
            "example": 16000000
          },
          "commentCount": {
            "type": "integer",
            "nullable": true,
            "example": 2500000
          },
          "thumbnails": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/ThumbnailItem"
            }
          },
          "thumbnail": {
            "type": "string",
            "example": "https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg"
          },
          "links": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": ["https://www.rickastley.co.uk"]
          },
          "timestamps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimestampItem"
            }
          }
        }
      },
      "ThumbnailItem": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string"
          },
          "width": {
            "type": "integer",
            "nullable": true
          },
          "height": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "TimestampItem": {
        "type": "object",
        "properties": {
          "time": {
            "type": "string",
            "example": "0:00"
          },
          "seconds": {
            "type": "integer",
            "example": 0
          },
          "label": {
            "type": "string",
            "example": "Intro"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "code": {
            "type": "string",
            "example": "INVALID_URL"
          },
          "message": {
            "type": "string",
            "example": "Please enter a valid YouTube video URL."
          }
        }
      }
    }
  }
}
