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

youtubei.js / Session

Class: Session

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

Represents an InnerTube session. This holds all the data needed to make requests to YouTube.

Extends

  • EventEmitter<SessionEvents>

Constructors

Constructor

new Session(context, api_key, api_version, account_index, config_data?, player?, cookie?, fetch?, cache?, po_token?): Session

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

Parameters

context

Context

api_key

string

api_version

string

account_index

number

config_data?

string

player?

Player

cookie?

string

fetch?

{(input, init?): Promise<Response>; (input, init?): Promise<Response>; }

cache?

ICache

po_token?

string

Returns

Session

Overrides

EventEmitter.constructor

Properties

account_index

account_index: number

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


actions

actions: Actions

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


api_key

api_key: string

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


api_version

api_version: string

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


cache?

optional cache?: ICache

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


config_data?

optional config_data?: string

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


context

context: Context

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


cookie?

optional cookie?: string

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


http

http: HTTPClient

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


logged_in

logged_in: boolean

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


oauth

oauth: OAuth2

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


player?

optional player?: Player

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


po_token?

optional po_token?: string

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


user_agent?

optional user_agent?: string

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

Accessors

client_name

Get Signature

get client_name(): string

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

Returns

string


client_version

Get Signature

get client_version(): string

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

Returns

string


lang

Get Signature

get lang(): string

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

Returns

string

Methods

emit()

emit<K>(type, ...args): void

Defined in: src/utils/EventEmitterLike.ts:7

Type Parameters

K

K extends keyof SessionEvents

Parameters

type

K

args

...Parameters<SessionEvents[K]>

Returns

void

Inherited from

EventEmitter.emit


off()

off<K>(type, listener): void

Defined in: src/utils/EventEmitterLike.ts:45

Type Parameters

K

K extends keyof SessionEvents

Parameters

type

K

listener

SessionEvents[K]

Returns

void

Inherited from

EventEmitter.off


on()

on<K>(type, listener): void

Defined in: src/utils/EventEmitterLike.ts:17

Type Parameters

K

K extends keyof SessionEvents

Parameters

type

K

listener

SessionEvents[K]

Returns

void

Inherited from

EventEmitter.on


once()

once<K>(type, listener): void

Defined in: src/utils/EventEmitterLike.ts:28

Type Parameters

K

K extends keyof SessionEvents

Parameters

type

K

listener

SessionEvents[K]

Returns

void

Inherited from

EventEmitter.once


removeAllListeners()

removeAllListeners(type?): void

Defined in: src/utils/EventEmitterLike.ts:70

Parameters

type?

keyof SessionEvents

Returns

void

Inherited from

EventEmitter.removeAllListeners


signIn()

signIn(credentials?): Promise<void>

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

Parameters

credentials?

OAuth2Tokens

Returns

Promise<void>


signOut()

signOut(): Promise<Response | undefined>

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

Signs out of the current account and revokes the credentials.

Returns

Promise<Response | undefined>


create()

static create(options?): Promise<Session>

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

Parameters

options?

SessionOptions = {}

Returns

Promise<Session>


fromCache()

static fromCache(cache, session_args): Promise<SessionData | null>

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

Retrieves session data from cache.

Parameters

cache

ICache

A valid cache implementation.

session_args

SessionArgs

User provided session arguments.

Returns

Promise<SessionData | null>


getSessionData()

static getSessionData(lang?, location?, account_index?, visitor_data?, user_agent?, enable_safety_mode?, generate_session_locally?, fail_fast?, device_category?, client_name?, tz?, fetch?, on_behalf_of_user?, cache?, enable_session_cache?, po_token?, retrieve_innertube_config?): Promise<{ account_index: number; api_key: string; api_version: string; config_data?: string; context: Context; }>

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

Parameters

lang?

string = ''

location?

string = ''

account_index?

number = 0

visitor_data?

string = ''

user_agent?

string = ...

enable_safety_mode?

boolean = false

generate_session_locally?

boolean = false

fail_fast?

boolean = false

device_category?

DeviceCategory = 'desktop'

client_name?

ClientType = ClientType.WEB

tz?

string = ...

fetch?

{(input, init?): Promise<Response>; (input, init?): Promise<Response>; }

on_behalf_of_user?

string

cache?

ICache

enable_session_cache?

boolean = true

po_token?

string

retrieve_innertube_config?

boolean = true

Returns

Promise<{ account_index: number; api_key: string; api_version: string; config_data?: string; context: Context; }>

Edit this page
Last Updated: 10/20/26, 8:11 PM