The Player API covers everything needed to stream audio, build a queue, display lyrics, and track playback. 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>.
YouTube.player()
Fetches a PlayerResponse for a video, including stream URLs and playability status.
The YouTube video ID (e.g.
"dQw4w9WgXcQ").Optional playlist context ID. Pass the playlist ID when playing a song in a playlist for correct autoplay behaviour.
The client context to use. Common choices are
YouTubeClient.WEB_REMIX (YouTube Music) and YouTubeClient.WEB. The client determines which stream formats are returned.Signature timestamp for cipher decoding. Required when using clients that return signature-protected stream URLs. Obtain from the player JavaScript.
Proof-of-origin token for bot-check bypass. Leave
null unless you have obtained a valid token for the client.Returns
Result<PlayerResponse>
Playability indicator. Common values:
| Value | Meaning |
|---|---|
"OK" | Streams are available |
"LOGIN_REQUIRED" | Requires an authenticated cookie |
"AGE_CHECK_REQUIRED" | Age-gated content |
"UNPLAYABLE" | Content is unavailable in the current region |
"ERROR" | Generic server-side error |
Adaptive (DASH) audio and video streams. Each
Format carries itag, url, mimeType, bitrate, contentLength, and codec details. Audio-only streams have audioQuality set.Combined (progressive) audio+video streams. Typically lower quality and not always present.
Metadata including
videoId, title, author, lengthSeconds, thumbnail, and viewCount.Contains
loudnessDb for volume normalisation and perceptualLoudnessDb.URLs for CPB/CPH playback tracking. Pass the primary URL string to
registerPlayback().Example
YouTube.next()
Fetches the playback queue (upcoming tracks) for a given watch endpoint, automatically following automix for infinite radio playback.
Describes the current playback context. Common fields:
Opaque continuation token from a previous
NextResult.continuation. Pass null for the first call.Returns
Result<NextResult>
Queue title, e.g. the playlist name or
"Recommended".The list of upcoming tracks in the queue. When automix is triggered the method recursively resolves the automix endpoint and concatenates the results, so
items may contain many more entries than a single API page.Zero-based index of the currently-selected track within
items, or null if not determinable.Endpoint to pass to
lyrics() to fetch the lyrics for the current track.Endpoint to pass to
related() to fetch related songs, albums, and artists.Token for fetching more queue items. Pass this back as
continuation on the same endpoint.The effective watch endpoint used (may be the automix endpoint when automix was followed).
Example
YouTube.queue()
Fetches SongItem metadata for a list of video IDs or an entire playlist, without setting up full playback context.
Up to
YouTube.MAX_GET_QUEUE_SIZE (1000) video IDs. Provide either this or playlistId, not both.A playlist ID to bulk-resolve. Provide either this or
videoIds, not both.Returns
Result<List<SongItem>> — a flat list of resolved song items in request order.
The constant
YouTube.MAX_GET_QUEUE_SIZE = 1000 caps the number of videoIds that may be sent in a single request. An assert in the implementation enforces this limit.Example
YouTube.lyrics()
Fetches the plain-text lyrics for a track using the BrowseEndpoint from NextResult.lyricsEndpoint.
The lyrics browse endpoint. Obtain this from
NextResult.lyricsEndpoint after calling next().Returns
Result<String?> — the lyrics as a single plain-text string with newline-separated lines, or null when the track has no lyrics available.
Example
YouTube.transcript()
Fetches the auto-generated closed-caption transcript for a video, formatted as LRC with millisecond timestamps.
The YouTube video ID.
Returns
Result<String> — an LRC-formatted string where each line follows the pattern [MM:SS.mmm]text, e.g.:
Example
YouTube.registerPlayback()
Reports a playback event to YouTube’s tracking endpoint. Call this after starting playback to satisfy YouTube’s analytics requirements.
The playlist ID for the playback context, or
null for standalone video playback.The tracking URL string from
PlayerResponse.playbackTracking. The implementation automatically replaces s.youtube.com with music.youtube.com and generates a random 16-character client playback nonce (cpn) before firing the request.Returns
Result<*> — wraps the raw HTTP response; the body is not parsed. Treat any non-failure result as success.
YouTube.getMediaInfo()
Fetches rich metadata for a video, including dislike counts via the ReturnYouTubeDislike third-party API.
The YouTube video ID.
Returns
Result<MediaInfo>
Echo of the requested video ID.
Video title.
Channel display name.
Channel ID (e.g.
"UCxxxxxx").URL of the channel avatar thumbnail.
Full video description.
ISO 8601 upload date string (e.g.
"2009-10-25").Formatted subscriber count (e.g.
"15.8M subscribers").Exact view count as an integer.
Like count sourced from the YouTube API.
Dislike count sourced from the ReturnYouTubeDislike API. May be
null if the external service is unavailable.