youtubemusicapi is a Python 3 library to send requests to the YouTube Music API. It emulates YouTube Music web client requests using the user's cookie data for authentication.
It improves on the authentication mechanism and allows users who implement their choice of auth flow (OAuth 2.0 PKCE recommended for web based applications) to pass the auth token.
It decouples the library from using OAuth 2.0 for TV and Limited Input Devices.
This package is being used in production. I don't plan on updating the library with more features than I need. Contributions are open!
- inject token information from external client
- search (including all filters) and suggestions
- get artist information and releases (songs, videos, albums, singles, related artists)
- get user information (videos, playlists)
- get albums
- get song metadata
- get watch playlists (next songs when you press play/radio/shuffle in YouTube Music)
- get song lyrics
- get moods and genres playlists
- get latest charts (globally and per country)
- get library contents: playlists, songs, artists, albums and subscriptions
- add/remove library content: rate songs, albums and playlists, subscribe/unsubscribe artists
- get and modify play history
- create and delete playlists
- modify playlists: edit metadata, add/move/remove tracks
- get playlist contents
- get playlist suggestions
- upload songs and remove them again
- list uploaded songs, artists and albums
- all regions are supported (see locations FAQ
- 16 languages are supported (see languages FAQ
If you find something missing or broken, check the FAQ or feel free to create an issue.
from ytmusicapi import YTMusic
yt = YTMusic('oauth.json')
playlistId = yt.create_playlist('test', 'test description')
search_results = yt.search('Oasis Wonderwall')
yt.add_playlist_items(playlistId, [search_results[0]['videoId']])
The tests are also a great source of usage examples.
- Python 3.8 or higher - https://www.python.org
See the Documentation for detailed instructions
Pull requests are welcome. There are still some features that are not yet implemented. Please, refer to CONTRIBUTING.rst for guidance.