Skip to main content

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

The account API provides methods for fetching the authenticated user’s account details, obtaining visitor data required by unauthenticated requests, managing the music taste profile shown during onboarding, submitting generic feedback tokens, and resolving missing artist IDs across item lists. All suspend functions return Result<T>.

YouTube.accountInfo

Fetches the signed-in user’s display name, handle, and avatar from the account menu endpoint.
suspend fun accountInfo(): Result<AccountInfo>
Return type
Result<AccountInfo>
Result
Example
YouTube.accountInfo().onSuccess { info ->
    println("Signed in as: ${info.name} (${info.email})")
}

YouTube.visitorData

Fetches a fresh visitor data string from music.youtube.com/sw.js_data. Visitor data is a short Base64-encoded token that must be attached to every unauthenticated InnerTube request. After obtaining it, assign it to YouTube.visitorData.
suspend fun visitorData(): Result<String>
Return type
Result<String>
Result
The visitor data string, which begins with "Cgt" or "Cgs".
Example
YouTube.visitorData().onSuccess { vd ->
    YouTube.visitorData = vd
    println("Visitor data: $vd")
}

YouTube.getTasteProfile

Browses the FEmusic_tastebuilder page to retrieve the user’s taste profile. Currently returns an empty profile (TasteProfile(artists = emptyMap())); full parsing requires additional model support for musicTastebuilderShelfRenderer.
suspend fun getTasteProfile(): Result<TasteProfile>
Return type
Result<TasteProfile>
Result
Example
YouTube.getTasteProfile().onSuccess { profile ->
    println("Artists in profile: ${profile.artists.size}")
}

YouTube.setTasteProfile

Submits the user’s artist selections and impression tokens for all displayed artists to the feedback endpoint. Typically called after the user completes the taste-builder onboarding flow.
suspend fun setTasteProfile(
    selectedArtists: List<String>,
    allArtists: Map<String, TasteArtist>,
): Result<Unit>
selectedArtists
List<String>
required
Names of the artists the user selected. Each name must be a key in allArtists.
allArtists
Map<String, TasteArtist>
required
The complete artist map from TasteProfile.artists, used to look up selectionValue and impressionValue feedback tokens.
Return type
Result<Unit>
Result
Succeeds when the feedback endpoint accepted all tokens. A no-op (does not call feedback()) when selectedArtists maps to zero valid tokens.
Example
val profile = YouTube.getTasteProfile().getOrThrow()
val picks = listOf("Radiohead", "Portishead")
YouTube.setTasteProfile(picks, profile.artists).onSuccess {
    println("Taste profile updated.")
}

YouTube.feedback

Generic low-level method that submits one or more feedback tokens to the InnerTube feedback endpoint. Higher-level functions such as addSongToLibrary(), removeHistoryItems(), and setTasteProfile() all delegate to this method.
suspend fun feedback(tokens: List<String>): Result<Boolean>
tokens
List<String>
required
One or more opaque feedback token strings. Token sources include SongItem.libraryAddToken, SongItem.libraryRemoveToken, SongItem.historyRemoveToken, TasteArtist.selectionValue, and TasteArtist.impressionValue.
Return type
Result<Boolean>
Result
true when all feedbackResponse entries in the API response have isProcessed = true.
Example
song.libraryAddToken?.let { token ->
    YouTube.feedback(listOf(token)).onSuccess { ok ->
        if (ok) println("Song added to library via feedback.")
    }
}

YouTube.resolveArtistIds

For any YTItem in the list whose artist(s) have a null id, performs a parallel artist search (up to 8 concurrent requests) to fill in the missing IDs. Returns the updated list with the same ordering.
suspend fun resolveArtistIds(items: List<YTItem>): List<YTItem>
items
List<YTItem>
required
Any mix of SongItem, AlbumItem, PlaylistItem, EpisodeItem, and PodcastItem values. Items of other types are passed through unchanged.
Return type
List<YTItem>
List
A new list with the same elements and ordering. For items where an artist name matched a search result exactly (case-insensitive), the Artist.id field is now populated.
Example
val enriched = YouTube.resolveArtistIds(searchResult.items)
enriched.filterIsInstance<SongItem>().forEach { song ->
    song.artists.forEach { artist ->
        println("${artist.name} → id=${artist.id}")
    }
}

YouTube.resolveArtistIdMap

Same resolution logic as resolveArtistIds() but returns a Map<artistName, artistId> instead of the modified item list. Use this when you need to apply resolved IDs across multiple independently-fetched sections without running duplicate searches.
suspend fun resolveArtistIdMap(items: List<YTItem>): Map<String, String>
items
List<YTItem>
required
Items to collect missing artist names from. The same concurrency limit of 8 parallel searches applies.
Return type
Map<String, String>
Map
A map of artistName to resolved artistId. Only entries where a match was found are included. Returns an empty map when all artists already have IDs.
Example
// Resolve IDs across multiple sections at once
val allItems = homeSection1.items + homeSection2.items
val idMap = YouTube.resolveArtistIdMap(allItems)

// Apply the map manually
val updatedSongs = songs.map { song ->
    song.copy(
        artists = song.artists.map { artist ->
            artist.copy(id = artist.id ?: idMap[artist.name])
        }
    )
}

Build docs developers (and LLMs) love