youtubei.js / Session
Class: Session
Represents an InnerTube session. This holds all the data needed to make requests to YouTube.
Extends
Constructors
new Session()
new Session(
context
,api_key
,api_version
,account_index
,player
?,cookie
?,fetch
?,cache
?,po_token
?):Session
Parameters
• context: Context
• api_key: string
• api_version: string
• account_index: number
• player?: Player
• cookie?: string
• fetch?
• cache?: ICache
• po_token?: string
Returns
Overrides
Defined in
Properties
account_index
account_index:
number
Defined in
actions
actions:
Actions
Defined in
api_version
api_version:
string
Defined in
cache?
optional
cache:ICache
Defined in
context
context:
Context
Defined in
http
http:
HTTPClient
Defined in
key
key:
string
Defined in
logged_in
logged_in:
boolean
Defined in
oauth
oauth:
OAuth2
Defined in
player?
optional
player:Player
Defined in
po_token?
optional
po_token:string
Defined in
Accessors
client_name
get
client_name():string
Returns
string
Defined in
client_version
get
client_version():string
Returns
string
Defined in
lang
get
lang():string
Returns
string
Defined in
Methods
addEventListener()
addEventListener(
type
,callback
,options
?):void
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
Parameters
• type: string
• callback: null
| EventListenerOrEventListenerObject
• options?: boolean
| AddEventListenerOptions
Returns
void
Inherited from
Defined in
node_modules/.deno/[email protected]/node_modules/typescript/lib/lib.dom.d.ts:8303
dispatchEvent()
dispatchEvent(
event
):boolean
Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Parameters
• event: Event
Returns
boolean
Inherited from
Defined in
node_modules/.deno/[email protected]/node_modules/typescript/lib/lib.dom.d.ts:8309
emit()
emit(
type
, ...args
):void
Parameters
• type: string
• ...args: any
[]
Returns
void
Inherited from
Defined in
src/utils/EventEmitterLike.ts:10
off()
off(
type
,listener
):void
Parameters
• type: string
• listener
Returns
void
Inherited from
Defined in
src/utils/EventEmitterLike.ts:40
on()
on(type, listener)
on(
type
,listener
):void
Parameters
• type: "auth"
• listener: OAuth2AuthEventHandler
Returns
void
Overrides
Defined in
on(type, listener)
on(
type
,listener
):void
Parameters
• type: "auth-pending"
• listener: OAuth2AuthPendingEventHandler
Returns
void
Overrides
EventEmitter.on
Defined in
on(type, listener)
on(
type
,listener
):void
Parameters
• type: "auth-error"
• listener: OAuth2AuthErrorEventHandler
Returns
void
Overrides
EventEmitter.on
Defined in
on(type, listener)
on(
type
,listener
):void
Parameters
• type: "update-credentials"
• listener: OAuth2AuthEventHandler
Returns
void
Overrides
EventEmitter.on
Defined in
once()
once(type, listener)
once(
type
,listener
):void
Parameters
• type: "auth"
• listener: OAuth2AuthEventHandler
Returns
void
Overrides
Defined in
once(type, listener)
once(
type
,listener
):void
Parameters
• type: "auth-pending"
• listener: OAuth2AuthPendingEventHandler
Returns
void
Overrides
EventEmitter.once
Defined in
once(type, listener)
once(
type
,listener
):void
Parameters
• type: "auth-error"
• listener: OAuth2AuthErrorEventHandler
Returns
void
Overrides
EventEmitter.once
Defined in
removeEventListener()
removeEventListener(
type
,callback
,options
?):void
Removes the event listener in target's event listener list with the same type, callback, and options.
Parameters
• type: string
• callback: null
| EventListenerOrEventListenerObject
• options?: boolean
| EventListenerOptions
Returns
void
Inherited from
EventEmitter
.removeEventListener
Defined in
node_modules/.deno/[email protected]/node_modules/typescript/lib/lib.dom.d.ts:8315
signIn()
signIn(
credentials
?):Promise
<void
>
Parameters
• credentials?: OAuth2Tokens
Returns
Promise
<void
>
Defined in
signOut()
signOut():
Promise
<undefined
|Response
>
Signs out of the current account and revokes the credentials.
Returns
Promise
<undefined
| Response
>
Defined in
create()
static
create(options
):Promise
<Session
>
Parameters
• options: SessionOptions
= {}
Returns
Promise
<Session
>
Defined in
fromCache()
static
fromCache(cache
,session_args
):Promise
<null
|SessionData
>
Retrieves session data from cache.
Parameters
• cache: ICache
A valid cache implementation.
• session_args: SessionArgs
User provided session arguments.
Returns
Promise
<null
| SessionData
>
Defined in
getSessionData()
static
getSessionData(lang
,location
,account_index
,visitor_data
,enable_safety_mode
,generate_session_locally
,device_category
,client_name
,tz
,fetch
,on_behalf_of_user
?,cache
?,enable_session_cache
?,po_token
?):Promise
<object
>
Parameters
• lang: string
= ''
• location: string
= ''
• account_index: number
= 0
• visitor_data: string
= ''
• enable_safety_mode: boolean
= false
• generate_session_locally: boolean
= false
• device_category: DeviceCategory
= 'desktop'
• client_name: ClientType
= ClientType.WEB
• tz: string
= ...
• fetch = Platform.shim.fetch
• on_behalf_of_user?: string
• cache?: ICache
• enable_session_cache?: boolean
= true
• po_token?: string
Returns
Promise
<object
>
account_index
account_index:
number
api_key
api_key:
string
api_version
api_version:
string
context
context:
Context