ytmusicapi-rs
A Rust library for the YouTube Music API.
[!NOTE] 🚧 Work in Progress: currently implementing only playlist reading features. Search, library management, and uploads are not yet supported.
Features
- 🔐 Browser cookie authentication
- 📋 Playlist APIs: List library playlists, get playlist tracks
- ❤️ Liked Songs: Access your liked songs playlist
- 📄 Pagination: Automatic handling of large playlists
- 🦀 Idiomatic Rust: Builder pattern, strong typing, async/await
Installation
Add to your Cargo.toml:
[]
= { = "path/to/ytmusicapi-rs" }
= { = "1", = ["rt-multi-thread", "macros"] }
Quick Start
1. Get Your Browser Headers
- Open YouTube Music in your browser and log in
- Open Developer Tools (F12) → Network tab
- Find any request to
music.youtube.com - Copy the
cookieandx-goog-authuserheaders - Save as
headers.json:
2. Use the Library
use ;
async
API Reference
YTMusicClient
| Method | Description |
|---|---|
get_library_playlists(limit) |
Get all playlists from your library |
get_playlist(id, limit) |
Get a playlist with its tracks |
get_liked_songs(limit) |
Get your liked songs playlist |
Types
Playlist- Full playlist with metadata and tracksPlaylistSummary- Brief playlist info (for library listing)PlaylistTrack- Track within a playlistArtist,Album,Thumbnail- Common types
Examples
Run the example:
Acknowledgements
This library is a Rust port of ytmusicapi.
License
MIT License - see license for details.