youtubei.js / SessionOptions
Type Alias: SessionOptions
SessionOptions:
object
Type declaration
account_index?
optional
account_index:number
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
Used to cache algorithms, session data, and OAuth2 tokens.
client_type?
optional
client_type:ClientType
InnerTube client type.
cookie?
optional
cookie:string
YouTube cookies.
device_category?
optional
device_category:DeviceCategory
Platform to use for the session.
enable_safety_mode?
optional
enable_safety_mode:boolean
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
Specifies whether the session data should be cached.
fetch?
optional
fetch:FetchFunction
Fetch function to use.
generate_session_locally?
optional
generate_session_locally:boolean
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
Language.
location?
optional
location:string
Geolocation.
on_behalf_of_user?
optional
on_behalf_of_user:string
Specify the Page ID of the YouTube profile/channel to use, if the logged-in account has multiple profiles.
po_token?
optional
po_token:string
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 genuine client.
retrieve_player?
optional
retrieve_player:boolean
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
The time zone.
visitor_data?
optional
visitor_data:string
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.