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.

PlayerResponse is the raw deserialized response from the InnerTube /player endpoint. It is returned by YouTube.player() and is the primary source of stream URLs, video metadata, and playability information. All fields are modeled with kotlinx.serialization and map directly to the YouTube InnerTube API JSON schema.

PlayerResponse

The top-level player response object.
FieldTypeDescription
playabilityStatusPlayabilityStatusWhether the video can be played and why it cannot if not
streamingDataStreamingData?Available stream formats; null when the video is unplayable
videoDetailsVideoDetails?Metadata about the video (title, author, duration)
playerConfigPlayerConfig?Audio normalization settings
playbackTrackingPlaybackTracking?URLs for reporting playback statistics to YouTube

PlayabilityStatus

Indicates whether the video is playable in the current context.
FieldTypeDescription
statusStringPlayability status code (see table below)
reasonString?Human-readable explanation when the video is not playable

Status Values

StatusMeaningRecommended Action
OKStream is available and ready to playProceed with playback using streamingData
LOGIN_REQUIREDBot detection triggered or authentication requiredRotate visitorData, use a different client, or authenticate
AGE_CHECK_REQUIREDContent is age-restrictedRetry with WEB_CREATOR client and a logged-in session
AGE_VERIFICATION_REQUIREDAdditional age verification neededSame as above
CONTENT_CHECK_REQUIREDContent warning requires user acknowledgementUse a logged-in session with content check accepted
UNPLAYABLEVideo is unavailable, private, paid, or region-lockedCheck region settings; try a different client such as TVHTML5_SIMPLY_EMBEDDED_PLAYER

StreamingData

Contains all available audio and video stream formats for the video.
FieldTypeDescription
adaptiveFormatsList<Format>Separate audio-only and video-only streams (DASH adaptive bitrate)
formatsList<Format>?Combined audio+video streams at standard qualities; null for most music content
expiresInSecondsIntNumber of seconds until the stream URLs in this response expire
Stream URLs expire. Store expiresInSeconds and re-fetch the player response before the URLs go stale. YouTube typically returns 6-hour expiries.

StreamingData.Format

A single stream format entry within adaptiveFormats or formats.
FieldTypeDescription
itagIntYouTube format identifier. Determines codec, container, and quality tier
urlString?Direct stream URL. May be null for cipher-protected formats
signatureCipherString?Encoded cipher string requiring decryption via YouTubeExtractor.decryptUrl()
cipherString?Older name for signatureCipher — present in some client responses
mimeTypeStringMIME type with codec parameter, e.g. "audio/webm; codecs=\"opus\""
bitrateIntNominal bitrate in bits per second
averageBitrateInt?Average bitrate in bits per second
widthInt?Video width in pixels; null for audio-only formats
heightInt?Video height in pixels; null for audio-only formats
contentLengthLong?Total byte length of the stream, if known
qualityStringQuality label, e.g. "tiny", "small", "medium", "hd720"
qualityLabelString?Human-readable quality label for video, e.g. "720p"
fpsInt?Frames per second; null for audio-only formats
audioQualityString?Audio quality tier: "AUDIO_QUALITY_LOW", "AUDIO_QUALITY_MEDIUM", or "AUDIO_QUALITY_HIGH"
audioSampleRateInt?Audio sample rate in Hz (e.g. 48000)
audioChannelsInt?Number of audio channels (e.g. 2 for stereo)
loudnessDbDouble?Per-format loudness value for normalization
approxDurationMsString?Approximate stream duration in milliseconds as a string
lastModifiedLong?Unix timestamp (microseconds) when this format was last modified
audioTrackAudioTrack?Audio track metadata; present only for multi-audio formats

Computed Properties

PropertyTypeDescription
isAudioBooleantrue when width == null — i.e. this is an audio-only stream
isOriginalBooleantrue when audioTrack?.isAutoDubbed is null — filters out auto-dubbed alternative audio tracks

AudioTrack

Present on formats that are part of a multi-language or auto-dubbed track set.
FieldTypeDescription
displayNameString?Language display name (e.g. "English")
idString?Audio track identifier
isAutoDubbedBoolean?true if this track was auto-generated by YouTube’s dubbing system

Resolving Stream URLs

When url is null, the format uses a signature cipher. Decrypt it using YouTubeExtractor:
val format: PlayerResponse.StreamingData.Format = ...

val streamUrl = when {
    format.url != null -> {
        // Direct URL — still deobfuscate the throttle parameter
        YouTubeExtractor.deobfuscateUrlNParam(format.url)
    }
    format.signatureCipher != null -> {
        // Ciphered URL — decrypt signature and deobfuscate n param
        YouTubeExtractor.decryptUrl(format.signatureCipher)
    }
    format.cipher != null -> {
        YouTubeExtractor.decryptUrl(format.cipher)
    }
    else -> null
}

VideoDetails

Metadata about the video itself, independent of stream availability.
FieldTypeDescription
videoIdStringYouTube video ID
titleString?Video title
authorString?Channel/artist name
channelIdStringChannel ID of the uploader
lengthSecondsStringVideo duration in seconds as a string
musicVideoTypeString?Music video type string (e.g. "MUSIC_VIDEO_TYPE_ATV")
viewCountString?Total view count as a string
thumbnailThumbnailsThumbnail images at multiple resolutions

PlayerConfig

Audio configuration from the player, used for loudness normalization.
FieldTypeDescription
audioConfigAudioConfigAudio normalization settings

AudioConfig

FieldTypeDescription
loudnessDbDouble?Loudness adjustment value in decibels for this video
perceptualLoudnessDbDouble?Perceptual loudness normalization value
Use loudnessDb from PlayerConfig.audioConfig (or per-format loudnessDb) to implement loudness normalization in your player. Negative values mean the track is louder than the target and should be attenuated.

PlaybackTracking

URLs used to report playback events back to YouTube. Calling these URLs keeps play count and history accurate.
FieldTypeDescription
videostatsPlaybackUrlVideostatsPlaybackUrl?Base URL for reporting that playback started
videostatsWatchtimeUrlVideostatsWatchtimeUrl?Base URL for reporting ongoing watch time
atrUrlAtrUrl?Base URL for ATR (Adaptive Transport Rate) reporting
Each nested type exposes a single baseUrl: String? field containing the URL.

Usage with YouTube.registerPlayback()

val playerResponse = YouTube.player(
    videoId = "dQw4w9WgXcQ",
    playlistId = null
).getOrNull() ?: return

// Report that playback started
playerResponse.playbackTracking?.videostatsPlaybackUrl?.baseUrl?.let { url ->
    YouTube.registerPlayback(url)
}

Complete Example

val result = YouTube.player(videoId = "dQw4w9WgXcQ", playlistId = null)

result.onSuccess { playerResponse ->
    when (playerResponse.playabilityStatus.status) {
        "OK" -> {
            val streaming = playerResponse.streamingData ?: return@onSuccess

            // Pick the best audio-only format
            val audioFormat = streaming.adaptiveFormats
                .filter { it.isAudio && it.isOriginal }
                .maxByOrNull { it.bitrate }
                ?: return@onSuccess

            // Resolve the stream URL
            val streamUrl = if (audioFormat.url != null) {
                YouTubeExtractor.deobfuscateUrlNParam(audioFormat.url)
            } else {
                YouTubeExtractor.decryptUrl(
                    audioFormat.signatureCipher ?: audioFormat.cipher ?: return@onSuccess
                )
            }

            println("Stream URL: $streamUrl")
            println("Format: ${audioFormat.mimeType}, ${audioFormat.bitrate} bps")
            println("Expires in: ${streaming.expiresInSeconds}s")
        }
        "LOGIN_REQUIRED" -> println("Login required: ${playerResponse.playabilityStatus.reason}")
        "UNPLAYABLE" -> println("Unplayable: ${playerResponse.playabilityStatus.reason}")
    }
}

Build docs developers (and LLMs) love