Skip to main content

yspy

Youtube
Search.
PYthon.

Scrape YouTube search results, videos, channels, playlists and comments without the YouTube Data API v3. No API key required.

License: MIT Python: 3.10+ PyPI version


A refactored fork of youtube-search-python rebuilt around a clean-room code.

  • python >= 3.10
  • Sync (get_*, search, more, next) and async (aget_*, asearch, amore, anext) twins everywhere
    • Async is not just a wrapper for a sync API. Both have separate request paths.
  • Minimized unexpected network calls, behaviors

Install

Using uv & pip

pip install yspy # or: uv add yspy

Using pyproject.toml

[project]
dependencies = [
    "yspy"
]

Quick start (root / api layer)

from yspy import Search
from yspy.utils import SearchMode

# sync
search = Search.search('minecraft', SearchMode.VIDEO)
for video in search.videos:  # list[VideoResultElement]
    print(video.id, video.title)

# async
search = await Search.asearch('minecraft', SearchMode.PLAYLIST)
for playlist in search.playlists:  # list[PlaylistResultElement]
    print(playlist.title, playlist.channel_name)

SearchMode variants: VIDEO (default), CHANNEL, PLAYLIST, LIVESTREAM, or None(default) for mixed results.

Continuation pages follow the same rule everywhere: when there is no next page the call returns None instead of raising.

page = Search.search('minecraft', None)
while page is not None:
    print(len(page.videos), len(page.channels))
    page = page.more()  # None on the last page
# async: await page.amore()

Search results expose .videos, .channels, .playlists plus first_or / first_video_or / first_channel_or, and every element can fetch its own detail object (see below).

Video

from yspy import Video, VideoState

video, state = Video.get('https://www.youtube.com/watch?v=6sFi_F3DJX4')  # id or URL
if state is VideoState.OK:
    print(video.title, video.channel_name, video.view_count)

# async
video, state = await Video.aget('6sFi_F3DJX4')

Video.get / Video.aget return (Video | None, VideoState) instead of raising. VideoState.OK means the video is available; otherwise video is None and the state tells why:

  • MEMBERS_ONLY
  • RECORDING_UNAVAILABLE
  • AGE_RESTRICTED
  • BOT_DETECTION
  • LOGIN_REQUIRED
  • REGION_BLOCKED
  • COPYRIGHT_BLOCKED
  • PRIVATE
  • REMOVED_BY_UPLOADER
  • ACCOUNT_TERMINATED
  • REMOVED_FOR_TOS
  • UNAVAILABLE

The verdict is classified from the playability reason, so when a page comes back unavailable the library re-probes once with pot-free innertube clients (in English locale page).

video, state = await Video.aget('https://www.youtube.com/watch?v=C0Rs8MDpHsM')  # members-only
print(state)  # VideoState.MEMBERS_ONLY, video is None
# navigation (on a fetched Video — i.e. when state is OK)
channel = await video.aget_channel()  # Video -> Channel
comments = await video.aget_comments()  # Video -> Comments

Channel

from yspy import Channel

channel = Channel.get('@sleepground')  # handle, URL, or UC... id
print(channel.handle_name, channel.approx_subscriber_count)

detail = await channel.aget_detail()  # Channel -> ChannelDetail
print(detail.joined_date, detail.view_count, detail.country)

Playlist

from yspy import Playlist

playlist = Playlist.get('PL...')  # PL/UU id, VL id or /playlist?list= URL
print(playlist.title, len(playlist.videos))

# walk all pages
page = await playlist.anext()  # None on the last page
# uploads of a channel — 'UU' + channel_id[2:]
uploads = await Playlist.aget_from_channel(channel_id_or_url='@sleepground')
# or reuse an already fetched Channel object
uploads2 = Playlist.get_from_channel(channel=channel)

video = await playlist.videos[0].aget_video()  # PlaylistVideo -> Video

Comments

from yspy import Comments

comments = Comments.get('6sFi_F3DJX4')
while comments is not None:
    print(len(comments.comments))
    comments = comments.more()  # None when the comment feed ends

Suggestions

from yspy import Suggestion

s = await Suggestion.aget('mine')
print([item.text for item in s.suggestions])

Locale

YouTube renders localized count formats (573K subscribers vs 구독자 57.3만명). Counts are parsed from the english rendering, so a non-english locale fetches the same page twice internally — the english copy is used only for count parsing.

from yspy import Video
from yspy.utils import Locale, Language, Region, NONE_LOCALE, ENGLISH_LOCALE

ko = Locale(language=Language.KOREAN, region=Region.SOUTH_KOREA)
video = await Video.aget('6sFi_F3DJX4', ko)

# every instance method keeps the stored locale by default:
await video.aget_channel()  # keeps ko
await video.aget_channel(NONE_LOCALE)  # explicitly no locale
await video.aget_channel(ENGLISH_LOCALE)  # override

NONE_LOCALE is the default value of every fetch argument — it sends no hl/gl and in this case, the YouTube api usually falls back to the server/IP locale.

Element Navigation
VideoResultElement get_video/aget_video, get_channel/aget_channel
ChannelResultElement get_channel/aget_channel
PlaylistResultElement get_playlist/aget_playlist, get_channel/aget_channel

All elements also have get_highest_res_thumbnail() and carry component_data (the underlying parsed component).

Layer map

ysps is separated in a few of layers followed by their functions and responsibilities:

Layer What it does
yspy.api Domain objects & navigation (Video, Channel, Playlist, Search, ...)
yspy.request HTTP layer — innertube calls, returns raw httpx.Response JSON
yspy.data_parsing Pure parsing — raw JSON → frozen dataclasses, no I/O
yspy.utils Locale, SearchMode, path helpers

Lower layers are public and importable, so you can access to request + data_parsing layer directly without touching innertube requests.

Credits

Based on youtube-search-python (MIT). This project is not affiliated with YouTube.

Metadata

Release files for yspy 0.2.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 yspy 0.2.0
File Size Uploaded Provenance Actions
yspy-0.2.0.tar.gz 23.4 kB With provenance Details for yspy-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for yspy 0.2.0
File Interpreter ABI Platform Actions
yspy-0.2.0-py3-none-any.whl Python 3 none any Details for yspy-0.2.0-py3-none-any.whl

Total release size: 66.2 kB

Release files / yspy-0.2.0.tar.gz

Download URL yspy-0.2.0.tar.gz
Size 23.4 kB
Tags Source
SHA-256 checksum
How to use checksums
973ac2f0dac58b421719061b77575fd2cb198ced77b8da4fe9a07b368fe938af
BLAKE2b-256 checksum
How to use checksums
7bb2ae332c2e09e210bb5afce135fbebcd38b994a0a4b0e646d4e470b10df653
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release files / yspy-0.2.0-py3-none-any.whl

Download URL yspy-0.2.0-py3-none-any.whl
Size 42.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c482e22400710ebc385729d0787f7365bbf0c94f142b7de5662eb5f3f14e6c36
BLAKE2b-256 checksum
How to use checksums
7f15c44dfa1640fc012bf7555998d9c1e97685fad063389f1fc54db17e73710e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Security for yspy 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for yspy-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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