youtube-transcript-api errors

AgeRestricted in youtube-transcript-api

Why youtube-transcript-api cannot fetch age-restricted videos in version 1.2.4, how to detect them, and what that leaves you.

Running this on a server? TranscriptFetch returns the same transcript from any IP, no proxies. Try it free →

YouTube only plays age-restricted videos to signed-in adults, and in version 1.2.4 the library has no way to sign in.

The error

text
youtube_transcript_api._errors.AgeRestricted:
Could not retrieve a transcript for the video https://www.youtube.com/watch?v=VIDEO_ID! This is most likely caused by:

This video is age-restricted. Therefore, you are unable to retrieve transcripts for it without authenticating yourself.

Unfortunately, Cookie Authentication is temporarily unsupported in youtube-transcript-api, as recent changes in YouTube's API broke the previous implementation. I will do my best to re-implement it as soon as possible.

What triggers it

YouTube's player answers with a sign-in requirement and the reason "This video may be inappropriate for some users." The library raises AgeRestricted for exactly that answer.

What you can do

1. Detect and skip

There is no setting that gets past the age gate today, so catch it and move on:

python
from youtube_transcript_api import AgeRestricted, YouTubeTranscriptApi

try:
    transcript = YouTubeTranscriptApi().fetch(video_id)
except AgeRestricted:
    transcript = None  # needs a signed-in adult account

2. Watch for cookie authentication to return

The library used to accept a signed-in account's cookies and its error message says it will again. When it does, remember the library's own warning about cookies: YouTube can permanently ban the account you sign in with.

3. Don't reach for a proxy

The gate is about who is signed in, not where the request comes from, so a proxy or a different server changes nothing.

With TranscriptFetch

TranscriptFetch does not fetch age-restricted videos either. It answers with the error code age_restricted and does not charge for the attempt. For everything else this library struggles with on servers, see the other pages in this section.

FAQ

Is AgeRestricted an IP block?

No. The same video fails from any connection unless the request is signed in as an adult.

How can I tell which videos are age-restricted?

Catch AgeRestricted: the library raises it exactly when YouTube applies the age gate, which is the reliable signal.

Need transcripts that work from a server?

TranscriptFetch fetches YouTube, TikTok and Instagram transcripts from its own network, with AI transcription when a video has no captions. Free credits every month, no card.