youtubei.js / SessionOptions
Type Alias: SessionOptions
SessionOptions =
object
Defined in: src/core/Session.ts:129
Properties
account_index?
optionalaccount_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?
optionalcache?:ICache
Defined in: src/core/Session.ts:198
Used to cache algorithms, session data, and OAuth2 tokens.
client_type?
optionalclient_type?:ClientType
Defined in: src/core/Session.ts:190
InnerTube client type.
cookie?
optionalcookie?:string
Defined in: src/core/Session.ts:202
YouTube cookies.
device_category?
optionaldevice_category?:DeviceCategory
Defined in: src/core/Session.ts:186
Platform to use for the session.
enable_safety_mode?
optionalenable_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?
optionalenable_session_cache?:boolean
Defined in: src/core/Session.ts:182
Specifies whether the session data should be cached.
fail_fast?
optionalfail_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?
optionalfetch?:FetchFunction
Defined in: src/core/Session.ts:211
Fetch function to use.
generate_session_locally?
optionalgenerate_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?
optionallang?:string
Defined in: src/core/Session.ts:133
Language.
location?
optionallocation?:string
Defined in: src/core/Session.ts:137
Geolocation.
on_behalf_of_user?
optionalon_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?
optionalplayer_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?
optionalpo_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?
optionalretrieve_innertube_config?:boolean
Defined in: src/core/Session.ts:165
Specifies whether to retrieve the InnerTube config. Useful for "onesie" requests.
retrieve_player?
optionalretrieve_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?
optionaltimezone?:string
Defined in: src/core/Session.ts:194
The time zone.
user_agent?
optionaluser_agent?:string
Defined in: src/core/Session.ts:141
User agent (InnerTube requests only).
visitor_data?
optionalvisitor_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.