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.
YouTube is a Kotlin object (singleton) declared in com.metrolist.innertube. It is the only interface your application code needs to interact with — every search, browse, player, library, and account operation is exposed as a method on this single object. You never instantiate it; the JVM guarantees exactly one instance for the lifetime of the process.
Two-Layer Architecture
InnerTube is built on two cooperating layers.YouTube owns all the business logic: it parses raw JSON responses, maps renderer trees into typed page models, and returns clean Kotlin data classes. Underneath it, InnerTube handles the raw HTTP transport — building request bodies, managing ktor client configuration, computing authentication headers, and retrying transient I/O errors.
YouTube holds a private InnerTube instance and delegates all network calls to it. All configurable properties on YouTube are thin forwarding properties that read and write the underlying InnerTube field.
The Result Pattern
EveryYouTube method is a suspend function that returns Result<T>. Internally they all use runCatching { … }, which means network failures, HTTP errors, and parse exceptions are all captured as Failure variants — your coroutine is never interrupted by an unexpected exception from the library.
Because all methods are
suspend, they must be called from a coroutine context. Use viewModelScope.launch, lifecycleScope.launch, or any other coroutine scope appropriate for your application.Configurable Properties
ConfigureYouTube once at startup (for example in Application.onCreate) before making any API calls. All properties forward directly to the inner InnerTube instance.
Controls the geolocation (
gl) and host language (hl) sent with every request. Defaults to the device locale. Change this to request region-specific charts or localised search results.An opaque session token that YouTube uses to maintain continuity across requests (personalised recommendations, consistent radio queues). Call the separate
YouTube.visitorData() suspend function to fetch a fresh token from the API, then assign it here and persist it across app restarts.When set, this value is sent as
onBehalfOfUser inside every request context, allowing the server to return account-specific data (personalised playlists, liked songs, etc.). Obtain it from the authenticated account info response.A raw YouTube session cookie string (e.g.
"SAPISID=abc123; __Secure-3PSID=xyz..."). Setting this enables authenticated requests. The library automatically parses the cookie string and computes a SAPISIDHASH Authorization header for every request that requires login. See Authentication for details.An optional
Proxy for all HTTP traffic. Assigning a new value recreates the internal ktor HttpClient transparently — no restart required.A
Proxy-Authorization header value string to authenticate against a proxy that requires credentials.When
true, login headers are attached to every browse request regardless of whether the individual method explicitly opts in. Useful when you want the personalised home page, continue-watching state, or other account-level browse results on all endpoints.Typical Usage Pattern
Search Filters
YouTube.SearchFilter is a @JvmInline value class wrapping an encoded InnerTube params string. Pass a constant from its companion to the YouTube.search() method to restrict results to a specific content type.
FILTER_SONG
Returns audio tracks / official song recordings.
FILTER_VIDEO
Returns music videos and user-uploaded videos.
FILTER_ALBUM
Returns studio albums, EPs, and singles.
FILTER_ARTIST
Returns artist channel results.
FILTER_FEATURED_PLAYLIST
Returns curated / editorial playlists.
FILTER_COMMUNITY_PLAYLIST
Returns user-created community playlists.
FILTER_PODCAST
Returns podcast series.
FILTER_EPISODE
Returns individual podcast episodes.
FILTER_PROFILE
Returns YouTube profile / channel pages.
Library Filters
YouTube.LibraryFilter is also a @JvmInline value class wrapping an encoded continuation token. These are used internally by YouTube.libraryRecentActivity() and related library browsing methods to select which library view to load.
| Constant | Description |
|---|---|
FILTER_RECENT_ACTIVITY | Items most recently interacted with across the library. |
FILTER_RECENTLY_PLAYED | Albums and playlists in order of last playback. |
FILTER_PLAYLISTS_ALPHABETICAL | Liked and saved playlists sorted A → Z. |
FILTER_PLAYLISTS_RECENTLY_SAVED | Liked and saved playlists sorted by save date. |