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

youtubei.js / SessionOptions

Type Alias: SessionOptions

SessionOptions = object

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

Properties

account_index?

optional account_index: number

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

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

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


client_type?

optional client_type: ClientType

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

InnerTube client type.


cookie?

optional cookie: string

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

YouTube cookies.


device_category?

optional device_category: DeviceCategory

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

Platform to use for the session.


enable_safety_mode?

optional enable_safety_mode: boolean

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

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

Specifies whether the session data should be cached.


fetch?

optional fetch: FetchFunction

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

Fetch function to use.


generate_session_locally?

optional generate_session_locally: boolean

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

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

Language.


location?

optional location: string

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

Geolocation.


on_behalf_of_user?

optional on_behalf_of_user: string

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

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

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

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

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


retrieve_player?

optional retrieve_player: boolean

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

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

The time zone.


user_agent?

optional user_agent: string

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

User agent (InnerTube requests only).


visitor_data?

optional visitor_data: string

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

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/12/25, 3:23 PM