youtube-transcript-api is an open-source Python library and command line tool that retrieves the transcript (the subtitles) of a YouTube video. It also works for subtitles that YouTube generates automatically. It needs neither an API key nor a headless browser (a browser that a program controls without a window), unlike Selenium-based tools. The repository belongs to the GitHub user jdepoix.
A developer installs it with pip and calls fetch with a video ID. The result is a list of snippets, each with the text, a start time and a duration in seconds. A list of preferred language codes selects the transcript language, and YouTube's automatic translation can turn subtitles into another language. Formatters convert a transcript into plain text, JSON, WebVTT or SRT. Because YouTube blocks most IP addresses of cloud providers, the README explains how to send requests through rotating residential proxies.
The library is free and open source under the MIT license; contributors and sponsors keep it maintained.