The InnerTube SDK provides a complete set of methods for managing YouTube Music playlists: fetching content, creating new playlists, adding and removing tracks, reordering songs, and even uploading custom thumbnails. All write operations (create, rename, delete, add/remove/reorder songs, thumbnails) require a valid authenticated session set viaDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/faraasaaay/innertube-v1/llms.txt
Use this file to discover all available pages before exploring further.
YouTube.cookie.
All playlist management methods require the user to be signed in. Set
YouTube.cookie to a valid YouTube Music session cookie string before calling any write operation. Read operations like YouTube.playlist() also include authenticated state (such as the editable flag) when a cookie is present.Fetching a playlist
YouTube.playlist(playlistId) returns Result<PlaylistPage> containing the playlist metadata and the first page of tracks. The playlistId argument should be the bare playlist ID — without the VL prefix.
PlaylistPage fields
| Field | Type | Description |
|---|---|---|
playlist | PlaylistItem | Metadata: id, title, author, thumbnail, editable flag, description |
songs | List<SongItem> | First page of tracks; each SongItem carries a setVideoId required for remove/reorder |
songsContinuation | String? | Continuation token embedded in the track list (preferred for paging) |
continuation | String? | Fallback continuation token at the section list level |
Playlist continuation
For large playlists, pass the continuation token toYouTube.playlistContinuation() to fetch the next page of tracks. Repeat until continuation is null.
Creating a playlist
YouTube.createPlaylist(title) creates a new empty playlist and returns the new playlist ID as a String. This is a blocking call (backed by runBlocking internally) so call it from a coroutine or a background thread.
Renaming a playlist
Deleting a playlist
Adding songs
Add a single track
YouTube.addToPlaylist(playlistId, videoId) appends a single video to the end of a playlist.Removing songs
YouTube.removeFromPlaylist(playlistId, videoId, setVideoId) removes a specific track occurrence from a playlist. The setVideoId value comes from SongItem.setVideoId — it is the unique positional identifier that distinguishes duplicate tracks within the same playlist.
setVideoId is only populated when songs are fetched via YouTube.playlist() or YouTube.playlistContinuation(). It is null on SongItem objects returned from search or the library. Always load the playlist before removing or reordering its tracks.Reordering songs
YouTube.moveSongPlaylist(playlistId, setVideoId, successorSetVideoId) moves a track to the position immediately before the track identified by successorSetVideoId. Pass successorSetVideoId = null to move the track to the end of the playlist.
Custom thumbnails
Upload a custom thumbnail
YouTube.uploadCustomThumbnailLink(playlistId, imageBytes) is a two-step process handled automatically by the SDK:- It requests an upload URL from the YouTube image upload service (using
X-Goog-Upload-Command: start). - It uploads the raw image bytes and receives an encrypted blob ID.
- It calls
edit_playlistwith aSetCustomThumbnailActionto associate the blob with the playlist.
Result<String?> where the success value is the new thumbnail URL.VL prefix convention
Most
YouTube methods that accept a playlistId expect the bare ID without the VL prefix (for example PLxxxxxxxxxx or RDxxxxxxxxxx). The VL prefix is stripped automatically with removePrefix("VL") inside InnerTube.addToPlaylist, removeFromPlaylist, renamePlaylist, and similar methods.However, when the SDK calls the /browse endpoint internally (for example in YouTube.playlist()), it prepends VL to construct the browse ID (VL$playlistId). You never need to add or remove this prefix yourself.Complete playlist management example
Create, populate, and manage a playlist end to end
Create, populate, and manage a playlist end to end