YouTube.js
Guide
Discord
❤️ Sponsor
GitHub
Guide
Discord
❤️ Sponsor
GitHub

youtubei.js / SessionOptions

Type Alias: SessionOptions

SessionOptions = object

Defined in: src/core/Session.ts:128

Properties

account_index?

optional account_index: number

Defined in: src/core/Session.ts:146

The account index to use. This is useful if you have multiple accounts logged in.

NOTE: Only works if you are signed in with cookies.


cache?

optional cache: ICache

Defined in: src/core/Session.ts:197

Used to cache algorithms, session data, and OAuth2 tokens.


client_type?

optional client_type: ClientType

Defined in: src/core/Session.ts:189

InnerTube client type.


cookie?

optional cookie: string

Defined in: src/core/Session.ts:201

YouTube cookies.


device_category?

optional device_category: DeviceCategory

Defined in: src/core/Session.ts:185

Platform to use for the session.


enable_safety_mode?

optional enable_safety_mode: boolean

Defined in: src/core/Session.ts:160

Specifies whether to enable safety mode. This will prevent the session from loading any potentially unsafe content.


enable_session_cache?

optional enable_session_cache: boolean

Defined in: src/core/Session.ts:181

Specifies whether the session data should be cached.


fail_fast?

optional fail_fast: boolean

Defined in: src/core/Session.ts:177

If set to true, session creation will fail if it's not possible to retrieve session data from YouTube. If false, a local fallback will be used.


fetch?

optional fetch: FetchFunction

Defined in: src/core/Session.ts:210

Fetch function to use.


generate_session_locally?

optional generate_session_locally: boolean

Defined in: src/core/Session.ts:172

Specifies whether to generate the session data locally or retrieve it from YouTube. This can be useful if you need more performance.

NOTE: If you are using the cache option and a session has already been generated, this will be ignored. If you want to force a new session to be generated, you must clear the cache or disable session caching.


lang?

optional lang: string

Defined in: src/core/Session.ts:132

Language.


location?

optional location: string

Defined in: src/core/Session.ts:136

Geolocation.


on_behalf_of_user?

optional on_behalf_of_user: string

Defined in: src/core/Session.ts:150

Specify the Page ID of the YouTube profile/channel to use, if the logged-in account has multiple profiles.


player_id?

optional player_id: string

Defined in: src/core/Session.ts:220

Player ID override. In most cases, this isn't necessary; but when YouTube introduces breaking changes, forcing an older Player ID can help work around temporary issues.


po_token?

optional po_token: string

Defined in: src/core/Session.ts:214

Session bound Proof of Origin Token. This is an attestation token generated by BotGuard/DroidGuard. It is used to confirm that the request is coming from a real client.


retrieve_innertube_config?

optional retrieve_innertube_config: boolean

Defined in: src/core/Session.ts:164

Specifies whether to retrieve the InnerTube config. Useful for "onesie" requests.


retrieve_player?

optional retrieve_player: boolean

Defined in: src/core/Session.ts:156

Specifies whether to retrieve the JS player. Disabling this will make session creation faster.

NOTE: Deciphering formats is not possible without the JS player.


timezone?

optional timezone: string

Defined in: src/core/Session.ts:193

The time zone.


user_agent?

optional user_agent: string

Defined in: src/core/Session.ts:140

User agent (InnerTube requests only).


visitor_data?

optional visitor_data: string

Defined in: src/core/Session.ts:206

Setting this to a valid and persistent visitor data string will allow YouTube to give this session tailored content even when not logged in. A good way to get a valid one is by either grabbing it from a browser or calling InnerTube's /visitor_id endpoint.

Edit this page
Last Updated: 5/13/26, 3:20 AM