Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/vsmutok/ytscrape/llms.txt

Use this file to discover all available pages before exploring further.

YouTube.video() fetches detailed metadata for a single video and returns a VideoDetails dataclass. It accepts either a bare 11-character video id or any standard YouTube URL — no extra parsing needed on your side.

Calling yt.video()

Pass a video id or any URL that embeds one. The method extracts the id automatically from all common URL formats.
from ytscrape import YouTube

with YouTube() as yt:
    # Plain video id
    details = yt.video("dQw4w9WgXcQ")

    # Or any YouTube URL — all formats work
    details = yt.video("https://www.youtube.com/watch?v=dQw4w9WgXcQ")

Supported URL formats

FormatExample
watch?v=https://www.youtube.com/watch?v=dQw4w9WgXcQ
youtu.be/https://youtu.be/dQw4w9WgXcQ
/shorts/https://www.youtube.com/shorts/dQw4w9WgXcQ
/embed/https://www.youtube.com/embed/dQw4w9WgXcQ

Full example

The snippet below mirrors the official examples/03_video_details.py example and shows every commonly used field:
from ytscrape import YouTube

with YouTube() as yt:
    # A plain id or any YouTube URL both work.
    details = yt.video("https://www.youtube.com/watch?v=dQw4w9WgXcQ")

    print(f"Title:    {details.title}")
    print(f"Channel:  {details.channel}")
    print(f"Views:    {details.views}")
    print(f"Length:   {details.length_seconds}s")
    print(f"Live:     {details.is_live}")
    print(f"Keywords: {', '.join(details.keywords[:5])}")
    print(f"URL:      {details.url}")
You can also access the full description and the channel id for further lookups:
with YouTube() as yt:
    details = yt.video("dQw4w9WgXcQ")

    print(details.description)
    print(details.channel_id)    # UC…
    print(details.thumbnail)     # URL of the highest-resolution thumbnail

Field reference

VideoDetails is a frozen dataclass. All fields are listed below.
FieldTypeDescription
video_idstrUnique 11-character YouTube video id
titlestr | NoneVideo title
descriptionstr | NoneFull video description
channelstr | NoneDisplay name of the uploading channel
channel_idstr | NoneUC… id of the uploading channel
length_secondsint | NoneDuration of the video in seconds
viewsint | NoneTotal view count as an integer
keywordstuple[str, ...]Tags / keywords associated with the video
is_liveboolTrue if the video is currently a live stream
thumbnailstr | NoneURL of the highest-resolution available thumbnail
urlstrCanonical https://www.youtube.com/watch?v=… URL (computed property)
length_seconds is an int (e.g. 212), not a formatted string like "3:32". To display a human-readable duration, convert it yourself: f"{details.length_seconds // 60}:{details.length_seconds % 60:02d}".

Build docs developers (and LLMs) love