The Library API exposes the authenticated user’s saved songs, albums, playlists, artists, playback history, and account metadata. All methods areDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/faraasaaay/innertube-v2/llms.txt
Use this file to discover all available pages before exploring further.
suspend functions on the YouTube singleton and return Result<T>.
All library methods require a valid cookie to be set before calling:Without a cookie the requests will either fail or return an empty response.
YouTube.library()
Fetches a library tab for the authenticated user.
The library section to browse. Common values:
| Browse ID | Content |
|---|---|
"FEmusic_library_landing" | Main library landing page |
"FEmusic_liked_videos" | Liked songs |
"FEmusic_liked_playlists" | Liked / saved playlists |
"FEmusic_library_corpus_artists" | Subscribed artists |
"FEmusic_library_corpus_track_artists" | Artists from liked tracks |
Zero-based index of the tab within the browse page. Defaults to
0 (the first tab). Rarely needed — most library pages have only one tab.Returns
Result<LibraryPage>
The items in this library section. Depending on the
browseId, these will be one or more of SongItem, AlbumItem, PlaylistItem, or ArtistItem.Token for fetching more items via
libraryContinuation(). null when all items are on this page.LibraryFilter Constants
LibraryFilter is a Kotlin value class wrapping a URL-encoded continuation param string. The constants live in YouTube.LibraryFilter.Companion and are used internally by libraryRecentActivity() and can be passed as continuation tokens.
| Constant | Description | Encoded value |
|---|---|---|
FILTER_RECENT_ACTIVITY | Recently interacted items (mixed types) | 4qmFsgIrEhdGRW11c2ljX2xpYnJhcnlfbGFuZGluZxoQZ2dNR0tnUUlCaEFCb0FZQg%3D%3D |
FILTER_RECENTLY_PLAYED | Recently played songs | 4qmFsgIrEhdGRW11c2ljX2xpYnJhcnlfbGFuZGluZxoQZ2dNR0tnUUlCUkFCb0FZQg%3D%3D |
FILTER_PLAYLISTS_ALPHABETICAL | Liked playlists sorted A→Z | 4qmFsgIrEhdGRW11c2ljX2xpa2VkX3BsYXlsaXN0cxoQZ2dNR0tnUUlBUkFBb0FZQg%3D%3D |
FILTER_PLAYLISTS_RECENTLY_SAVED | Liked playlists sorted by date saved | 4qmFsgIrEhdGRW11c2ljX2xpa2VkX3BsYXlsaXN0cxoQZ2dNR0tnUUlBQkFCb0FZQg%3D%3D |
YouTube.libraryContinuation()
Fetches the next page of items from a library section.
The continuation token from
LibraryPage.continuation or a previous LibraryContinuationPage.continuation.Returns
Result<LibraryContinuationPage>
Next page of library items.
Token for the following page.
null when all items have been loaded.YouTube.libraryRecentActivity()
Fetches the user’s recently interacted items (songs, albums, playlists, artists) from the library landing page using the FILTER_RECENT_ACTIVITY continuation token.
Returns
Result<LibraryPage>
Mixed list of recently interacted
SongItem, AlbumItem, PlaylistItem, and ArtistItem entries, ordered by recency.For ArtistItem entries, the implementation automatically fetches the full artist page via artist() and injects the playEndpoint — which is absent in the library grid renderer. The thumbnail from the library grid is preserved so the square aspect ratio is maintained.Always
null — this endpoint returns a single page.YouTube.musicHistory()
Fetches the user’s full listening history grouped by time period.
Returns
Result<HistoryPage>
History grouped into time-period sections.
null if the response is empty (e.g. history is disabled).YouTube.accountInfo()
Fetches the display name, email, channel handle, and avatar thumbnail of the authenticated account.
Returns
Result<AccountInfo>
The Google account display name.
The Google account email address, if available in the account menu response.
The YouTube channel handle (e.g.
"@username"), if set.URL of the account profile picture thumbnail.
YouTube.refreshVisitorData()
Fetches a fresh visitorData token from YouTube and stores it in YouTube.visitorData. Call this on app launch for unauthenticated (guest) sessions to ensure accurate regional and localisation data.
Returns
Result<String> — the new visitor data string (also stored in YouTube.visitorData).
Example
YouTube.clearGuestSession()
Clears the stored visitorData and dataSyncId, effectively resetting the guest session context.
YouTube.visitorData and YouTube.dataSyncId are set to null. Use this when logging out or switching accounts.