Skip to main content

Class: Hoyolab

Represents the Hoyolab API client.

Constructors

constructor

new Hoyolab(options)

Creates a new instance of Hoyolab.

Throws

If ltuid or ltoken keys are missing in the ICookie object.

Remarks

Because CookieTokenV2 has a short expiration time and cannot be refreshed so far. It is evident that every few days, when logging in, it always requests authentication first. Therefore, this method that uses CookieTokenV2 is not suitable if filled statically.

Parameters

NameTypeDescription
optionsIHoyolabOptionsThe options to initialize the Hoyolab instance.

Defined in

src/client/hoyolab/hoyolab.ts:48

Properties

Readonly cookie: ICookie

The parsed ICookie object used to authenticate requests.

Defined in

src/client/hoyolab/hoyolab.ts:24


lang

lang: LanguageEnum

The language used for API responses.

Defined in

src/client/hoyolab/hoyolab.ts:34


request

Readonly request: HTTPRequest

The underlying Request object used to make HTTP requests.

Defined in

src/client/hoyolab/hoyolab.ts:29

Methods

gameAccount

gameAccount(game): Promise<IGame>

Get the account of a specific game from the games list.

Async

Throws

If there is no game account on this hoyolab account.

Remarks

Because CookieTokenV2 has a short expiration time and cannot be refreshed so far. It is evident that every few days, when logging in, it always requests authentication first. Therefore, this method that uses CookieTokenV2 is not suitable if filled statically.

Parameters

NameTypeDescription
gameGamesEnumThe game that the account belongs to.

Returns

Promise<IGame>

The game account.

Defined in

src/client/hoyolab/hoyolab.ts:151


gameRecordCard

gameRecordCard(): Promise<IGameRecordCard>

Retrieves the game record card

Async

Returns

Promise<IGameRecordCard>

The game account.

Defined in

src/client/hoyolab/hoyolab.ts:172


gamesList

gamesList(game?): Promise<IGame[]>

Get the list of games on this Hoyolab account.

Async

Throws

Thrown if there are no game accounts on this Hoyolab account.

Remarks

Because CookieTokenV2 has a short expiration time and cannot be refreshed so far. It is evident that every few days, when logging in, it always requests authentication first. Therefore, this method that uses CookieTokenV2 is not suitable if filled statically.

Parameters

NameTypeDescription
game?GamesEnumThe optional game for which to retrieve accounts.

Returns

Promise<IGame[]>

The list of games on this Hoyolab account.

Defined in

src/client/hoyolab/hoyolab.ts:94