Skip to main content

Documentation 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.

YTItem is the sealed base class for every content type returned by InnerTube. All search results, browse items, playlist entries, and artist section contents are one of its four concrete subtypes: SongItem, AlbumItem, PlaylistItem, or ArtistItem.

sealed class YTItem

Abstract fields shared by every subtype.
FieldTypeDescription
idStringUnique identifier for the item (videoId, browseId, or playlistId depending on subtype)
titleStringHuman-readable display name
thumbnailString?URL of the item’s thumbnail image
explicitBooleanWhether the content is marked as explicit
shareLinkStringComputed shareable URL for the item

data class SongItem : YTItem

Represents a single track — either an audio-only song (ATV) or a music video.
FieldTypeDescription
idStringYouTube video ID (videoId)
titleStringTrack title
artistsList<Artist>One or more artists credited on this track
albumAlbum?Album the track belongs to, or null for singles/orphans
durationInt?Track length in seconds, or null if unavailable
musicVideoTypeString?Raw music video type string from the API (e.g. "MUSIC_VIDEO_TYPE_ATV")
chartPositionInt?Ranking position when returned in a charts context
chartChangeString?Chart trend indicator (e.g. "UP", "DOWN", "SAME")
thumbnailStringThumbnail URL (non-null for songs)
explicitBooleanWhether the track is marked explicit (default false)
endpointWatchEndpoint?Watch endpoint for initiating playback
setVideoIdString?Playlist-scoped ID used for playlist mutation operations
libraryAddTokenString?Opaque token for adding the track to the library
libraryRemoveTokenString?Opaque token for removing the track from the library
historyRemoveTokenString?Opaque token for removing the track from history
viewCountTextString?Formatted view count string (e.g. "1.2M views")

Computed Properties

PropertyTypeDescription
isVideoSongBooleantrue when musicVideoType is non-null and is not MUSIC_VIDEO_TYPE_ATV — i.e. this is a music video, not an audio-only track
shareLinkStringhttps://music.youtube.com/watch?v={id}

data class AlbumItem : YTItem

Represents a full album or EP.
FieldTypeDescription
browseIdStringBrowse ID used to fetch the full album page (e.g. MPREb_…)
playlistIdStringPlaylist ID used to stream all album tracks
idStringDefaults to browseId
titleStringAlbum title
artistsList<Artist>?Album artist(s), may be null in some contexts
yearInt?Release year, if available
thumbnailStringAlbum artwork URL
explicitBooleanWhether the album is marked explicit (default false)
descriptionString?Album description text, if available
shareLinkStringhttps://music.youtube.com/playlist?list={playlistId}

data class PlaylistItem : YTItem

Represents a user-created or auto-generated playlist.
FieldTypeDescription
idStringPlaylist ID (without VL prefix)
titleStringPlaylist title
authorArtist?The playlist’s owner or creator
songCountTextString?Formatted song count (e.g. "42 songs")
thumbnailString?Playlist cover thumbnail URL
playEndpointWatchEndpoint?Endpoint to begin sequential playback
shuffleEndpointWatchEndpoint?Endpoint to begin shuffle playback
radioEndpointWatchEndpoint?Endpoint to start a radio based on this playlist
isEditableBooleanWhether the current user can modify this playlist (default false)
descriptionString?Playlist description text, if available
explicitBooleanAlways false — playlists do not carry explicit flags
shareLinkStringhttps://music.youtube.com/playlist?list={id}

data class ArtistItem : YTItem

Represents a YouTube Music artist or channel.
FieldTypeDescription
idStringArtist browse ID (e.g. UCxxxxxx)
titleStringArtist display name
thumbnailString?Artist profile image URL
channelIdString?YouTube channel ID, if available
playEndpointWatchEndpoint?Endpoint to play the artist’s top songs
shuffleEndpointWatchEndpoint?Endpoint to shuffle the artist’s songs
radioEndpointWatchEndpoint?Endpoint to start an artist radio
subtextString?Secondary text shown beneath the name (e.g. subscriber count or genre)
explicitBooleanAlways false
shareLinkStringhttps://music.youtube.com/channel/{id}

data class Artist

A lightweight artist reference used inside SongItem and AlbumItem. Not the same as ArtistItem.
FieldTypeDescription
nameStringArtist display name
idString?Browse ID of the artist, or null if not linkable

data class Album

A lightweight album reference used inside SongItem.
FieldTypeDescription
nameStringAlbum display name
idStringBrowse ID of the album (always present)

Extension Functions

Three filter extensions are defined on List<T : YTItem> for common content-filtering scenarios.

filterExplicit

fun <T : YTItem> List<T>.filterExplicit(enabled: Boolean = true): List<T>
Removes items where explicit == true when enabled is true. Pass enabled = false to disable filtering (returns the original list unchanged).

filterVideoSongs

fun <T : YTItem> List<T>.filterVideoSongs(disableVideos: Boolean = false): List<T>
Removes SongItem entries where isVideoSong == true when disableVideos is true. Useful for music-only playback modes.

filterYoutubeShorts

fun <T : YTItem> List<T>.filterYoutubeShorts(enabled: Boolean = false): List<T>
Removes PlaylistItem entries whose ID starts with "SS" (YouTube Shorts playlists) when enabled is true. Disabled by default.

Pattern Matching Example

Use a when expression to dispatch on the concrete subtype:
fun handleItem(item: YTItem) {
    when (item) {
        is SongItem -> {
            println("Song: ${item.title} by ${item.artists.joinToString { it.name }}")
            println("Duration: ${item.duration}s, isVideoSong: ${item.isVideoSong}")
            println("Share: ${item.shareLink}")
        }
        is AlbumItem -> {
            println("Album: ${item.title} (${item.year})")
            println("Browse ID: ${item.browseId}, Playlist ID: ${item.playlistId}")
        }
        is PlaylistItem -> {
            println("Playlist: ${item.title}${item.songCountText}")
            println("Editable: ${item.isEditable}")
        }
        is ArtistItem -> {
            println("Artist: ${item.title}")
            println("Share: ${item.shareLink}")
        }
    }
}

Applying Filters

val items: List<YTItem> = YouTube.search("lofi beats").getOrNull()?.items ?: emptyList()

val filtered = items
    .filterExplicit(enabled = true)          // remove explicit tracks
    .filterVideoSongs(disableVideos = true)  // audio-only
    .filterYoutubeShorts(enabled = true)     // no Shorts playlists

Build docs developers (and LLMs) love