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

youtubei.js / SessionOptions

Type Alias: SessionOptions

SessionOptions = object

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

Properties

account_index?

optional account_index?: number

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

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:198

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


client_type?

optional client_type?: ClientType

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

InnerTube client type.


cookie?

optional cookie?: string

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

YouTube cookies.


device_category?

optional device_category?: DeviceCategory

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

Platform to use for the session.


enable_safety_mode?

optional enable_safety_mode?: boolean

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

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:182

Specifies whether the session data should be cached.


fail_fast?

optional fail_fast?: boolean

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

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:211

Fetch function to use.


generate_session_locally?

optional generate_session_locally?: boolean

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

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:133

Language.


location?

optional location?: string

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

Geolocation.


on_behalf_of_user?

optional on_behalf_of_user?: string

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

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:221

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:215

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:165

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


retrieve_player?

optional retrieve_player?: boolean

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

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:194

The time zone.


user_agent?

optional user_agent?: string

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

User agent (InnerTube requests only).


visitor_data?

optional visitor_data?: string

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

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: 10/20/26, 8:11 PM