Skip to main content

YouTube Transcript/Subtitle API (including automatically generated subtitles)

This is an python API which allows you to get the transcripts/subtitles for a given YouTube video. It also works for automatically generated subtitles and it does not require a headless browser, like other selenium based solutions do!

Install

It is recommended to install this module by using pip:

pip install youtube_transcript_api

If you want to use it from source, you'll have to install the dependencies manually:

pip install -r requirements.txt

How to use it

You could either integrate this module into an existing application, or just use it via an CLI

In code

To get a transcript for a given video you can do:

from youtube_transcript_api import YouTubeTranscriptApi

YouTubeTranscriptApi.get_transcript(video_id)

This will return a list of dictionaries looking somewhat like this:

[
    {
        'text': 'Hey there',
        'start': 7.58,
        'duration': 6.13
    },
    {
        'text': 'how are you',
        'start': 14.08,
        'duration': 7.58
    },
    # ...
]

To get transcripts for a list fo video ids you can call:

YouTubeTranscriptApi.get_transcripts(video_ids)

CLI

Execute the CLI script using the video ids as parameters and the results will be printed out to the command line:

youtube_transcript_api <first_video_id> <second_video_id> ...

If you would prefer to write it into a file or pipe it into another application, you can also output the results as json using the following line:

youtube_transcript_api --json <first_video_id> <second_video_id> ... > transcripts.json

Warning

This code uses an undocumented part of the YouTube API, which is called by the YouTube web-client. So there is no guarantee that it won't stop working tomorrow, if they change how things work. I will however do my best to make things working again as soon as possible if that happens. So if it stops working, let me know!

Release files for youtube-transcript-api 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for youtube-transcript-api 0.1.0
File Size Uploaded
youtube_transcript_api-0.1.0.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for youtube-transcript-api 0.1.0
File Interpreter ABI Platform
youtube_transcript_api-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.0 kB

Release files / youtube_transcript_api-0.1.0.tar.gz

Download URL youtube_transcript_api-0.1.0.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
44b43c384b10582d5def4572c330e5e31bc5f968cd3611f2840a7565a9cf4a44
BLAKE2b-256 checksum
How to use checksums
0a4ecd109c9a9b4d58db207bb48f47e397c44e2cc192df99bfef83b776496993
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / youtube_transcript_api-0.1.0-py3-none-any.whl

Download URL youtube_transcript_api-0.1.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0f5acedc694ad4c94bbe7d055492d7e858540dddaa9f788bfba010b32d053dbf
BLAKE2b-256 checksum
How to use checksums
2b42ecdf0410862dca1e725cd0dda2e561be072c96cf33775c07d239ea37d151
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page