ytmusicapi
Unofficial API for YouTube Music
What it is and what it does
ytmusicapi is an unofficial Python library that lets you interact with YouTube Music programmatically by emulating web client requests using your account credentials. It wraps the YouTube Music API to provide a Python interface for common tasks like searching, browsing artist information, managing playlists, uploading songs, and accessing your library.
The library handles authentication through cookie or OAuth data and supports a wide range of operations: searching with filters, retrieving song metadata and lyrics, managing playlists and library content, accessing charts and mood playlists, and working with podcasts and uploads. It supports multiple languages and regions, making it useful for building automation tools, music discovery scripts, or integrations that need programmatic access to YouTube Music.
Use it for:
- Automate playlist creation and management by searching for songs and adding them programmatically.
- Build a music discovery tool that retrieves charts, moods, and artist information across regions.
- Sync or backup your YouTube Music library contents (playlists, songs, uploads) to external storage.
- Create a bot or script that modifies your play history or rates songs based on custom logic.
- Integrate YouTube Music data into a personal music application or dashboard.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
ytmusicapi lets you programmatically interact with YouTube Music by sending authenticated requests to its API, enabling you to search, browse, manage playlists, and control your library.
Yes. ytmusicapi is actively maintained, has low install friction, carries no known vulnerabilities, uses a permissive MIT license, and solves a clear problem—programmatic access to YouTube Music. It's well-suited for automation and integration tasks. The main caveat is that it's unofficial and depends on YouTube Music's internal API, so changes on YouTube's side could break functionality without notice.
Install
ytmusicapi on PyPI
pip
pip install ytmusicapiuv
uv add ytmusicapipoetry
poetry add ytmusicapiInstalling ytmusicapi
Before you install
Low install friction with a single dependency (requests). Actively maintained with a recent release 6 days ago and 2940 repository stars, indicating steady community engagement.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both personal and commercial projects.
Quickstart
from ytmusicapi import YTMusic
yt = YTMusic('oauth.json')
playlist_id = yt.create_playlist('test', 'test description')
results = yt.search('Oasis Wonderwall')
yt.add_playlist_items(playlist_id, [results[0]['videoId']])
Requires Python 3.10 or higher and valid YouTube Music authentication credentials (oauth.json file).
Verify before relying
- Whether YouTube Music API changes could break this library without warning, given its unofficial nature.
- Cookie-based authentication stability and whether account restrictions apply to programmatic access.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — requests |
| Maintenance | actively maintained — 6 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 330,939/month — #7,526 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ytmusicapi-1.12.2-py3-none-any.whl
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
casttubeInteract with YouTube on Chromecast devices by…
permissive · top 15,000 on PyPI
music-assistant-clientPython async client library for connecting to…
permissive · top 15,000 on PyPI
shazamioAsynchronous Python library that recognizes…
permissive · top 15,000 on PyPI
spotifywebapipythonA Python library that wraps the Spotify Web…
permissive · top 15,000 on PyPI
youtube-search-pythonSearch YouTube for videos, channels, and…
permissive · top 15,000 on PyPI
spotdlspotDL downloads songs from Spotify playlists…
permissive · top 15,000 on PyPI
discogs-clientA Python client library for querying and…
permissive · top 15,000 on PyPI
spotapiSpotAPI wraps Spotify's private and public APIs…
unclear · top 15,000 on PyPI
yelpapiyelpapi wraps the Yelp Fusion API, letting you…
permissive · top 15,000 on PyPI
gkeepapigkeepapi is an unofficial client library for…
permissive · top 15,000 on PyPI