Example Usage

Hoyolab

Usage

import { Hoyolab, LanguageEnum } from 'node-hoyolab'

const hoyolab = new Hoyolab({
    cookie: {
      ltokenV2: 'your token',
      ltuidV2: parseInt('12345677')
    },
  lang: LanguageEnum.ENGLISH,
})

Retrive Games Accounts

import { GamesEnum, Hoyolab, LanguageEnum } from 'node-hoyolab'

async function main() {
  const hoyolab = new Hoyolab({
    cookie: {
      ltokenV2: 'your token',
      ltuidV2: parseInt('12345677')
    },
    lang: LanguageEnum.ENGLISH,
  })

  // Fetch all user game accounts from all servers
  const games = hoyolab.gamesList()
  console.log(games)

  // Fetch one game account that has the highest level from all servers
  const genshinAccount = hoyolab.gamesList(GamesEnum.GENSHIN_IMPACT)
  console.log(genshinAccount)
}

main()

Find out more reference in Hoyolab API Refence

Genshin Impact

Usage

There are several methods to instantiate an object from the GenshinImpact class.

The following method will instantiate an object with the provided data.

import { GenshinImpact, LanguageEnum } from 'node-hoyolab'

const genshin = new GenshinImpact({
    cookie: {
      ltokenV2: 'your token',
      ltuidV2: parseInt('12345677')
    }, // Required. Cookie can be string or object, see the api refeence below
  lang: LanguageEnum.ENGLISH, // optional
  uid: 837_678_687, // Several modules will require UID, which if not filled in will throw an error.
})

Meanwhile, the method below will instantiate an object with some automatically filled data like UID, and will return a Promise.

import { GenshinImpact, LanguageEnum } from 'node-hoyolab'

const genshin = GenshinImpact.create({
    cookie: {
      ltokenV2: 'your token',
      ltuidV2: parseInt('12345677')
    }, // Required. Cookie can be string or object, see the api refeence below
  lang: LanguageEnum.ENGLISH, // optional
})

Game Records

import { GenshinImpact, LanguageEnum } from 'node-hoyolab'

async function main() {
  const genshin = new GenshinImpact({
    cookie: {
      ltokenV2: 'your token',
      ltuidV2: parseInt('12345677')
    },
    lang: LanguageEnum.ENGLISH,
  })

  // Retrieves information about the player's performance in the Spiral Abyss.
  const spiralAbyss = await genshin.record.spiralAbyss()
  console.log(spiralAbyss)

  // Retrieves the Genshin characters of the user.
  const characters = await genshin.record.characters()
  console.log(characters)

  // Get user's Genshin Impact game record
  const gameRecord = await genshin.record.records()
  console.log(gameRecord)

  const dailyNote = await genshin.record.dailyNote()
  console.log(dailyNote)
}

main()

Daily Checkin

import { GenshinImpact, LanguageEnum } from 'node-hoyolab'

async function main() {
  const genshin = new GenshinImpact({
    cookie: {
      ltokenV2: 'your token',
      ltuidV2: parseInt('12345677')
    },
    lang: LanguageEnum.ENGLISH,
  })

  // Claim the daily rewards.
  const claim = await genshin.daily.claim()
  console.log(claim)

  // Retrieves daily information.
  const dailyInfo = await genshin.daily.info()
  console.log(dailyInfo)

  // Retrieve daily rewards information.
  const rewards = await genshin.daily.rewards()
  console.log(rewards)

  // Get the daily reward for a specific day or the current day
  const reward = await genshin.daily.reward()
  console.log(reward)
}

main()

Redeem Code

import { GenshinImpact, LanguageEnum } from 'node-hoyolab'
async function main() {
  const genshin = new GenshinImpact({
    cookie: {
      ltokenV2: 'your token',
      ltuidV2: parseInt('12345677')
    },
    lang: LanguageEnum.ENGLISH,
  })

  const redeem = genshin.redeem.claim('GENSHINGIFT')
  console.log(redeem)
}

main()
Honkai Star Rail

Usage

There are several methods to instantiate an object from the HonkaiStarRail class.

The following method will instantiate an object with the provided data.

import { HonkaiStarRail, LanguageEnum } from 'node-hoyolab'

const hsr = new HonkaiStarRail({
    cookie: {
      ltokenV2: 'your token',
      ltuidV2: parseInt('12345677')
    }, // Required. Cookie can be string or object, see the api refeence below
  lang: LanguageEnum.ENGLISH, // optional
  uid: 837_678_687, // Several modules will require UID, which if not filled in will throw an error.
})

Meanwhile, the method below will instantiate an object with some automatically filled data like UID, and will return a Promise.

import { HonkaiStarRail, LanguageEnum } from 'node-hoyolab'

const hsr = HonkaiStarRail.create({
    cookie: {
      ltokenV2: 'your token',
      ltuidV2: parseInt('12345677')
    }, // Required. Cookie can be string or object, see the api refeence below
  lang: LanguageEnum.ENGLISH, // optional
})

Find out more reference in Honkai Star Rail API Refence

Honkai Impact

Usage

There are several methods to instantiate an object from the HonkaiImpact class.

The following method will instantiate an object with the provided data.

import { HonkaiImpact, LanguageEnum } from 'node-hoyolab'

const hi = new HonkaiImpact({
    cookie: {
      ltokenV2: 'your token',
      ltuidV2: parseInt('12345677')
    }, // Required. Cookie can be string or object, see the api refeence below
  lang: LanguageEnum.ENGLISH, // optional
  uid: 837_678_687, // Several modules will require UID, which if not filled in will throw an error.
})

Meanwhile, the method below will instantiate an object with some automatically filled data like UID, and will return a Promise.

import { HonkaiImpact, LanguageEnum } from 'node-hoyolab'

const hi = HonkaiImpact.create({
    cookie: {
      ltokenV2: 'your token',
      ltuidV2: parseInt('12345677')
    }, // Required. Cookie can be string or object, see the api refeence below
  lang: LanguageEnum.ENGLISH, // optional
})

Find out more reference in Honkai Impact API Refence

Zenless Zone Zero

Usage

There are several methods to instantiate an object from the ZenlessZoneZero class.

The following method will instantiate an object with the provided data.

import { ZenlessZoneZero, LanguageEnum } from 'node-hoyolab'

const zzz = new ZenlessZoneZero({
    cookie: {
      ltokenV2: 'your token',
      ltuidV2: parseInt('12345677')
    }, // Required. Cookie can be string or object, see the api refeence below
  lang: LanguageEnum.ENGLISH, // optional
  uid: 837_678_687, // Several modules will require UID, which if not filled in will throw an error.
})

Meanwhile, the method below will instantiate an object with some automatically filled data like UID, and will return a Promise.

import { ZenlessZoneZero, LanguageEnum } from 'node-hoyolab'

const zzz = ZenlessZoneZero.create({
    cookie: {
      ltokenV2: 'your token',
      ltuidV2: parseInt('12345677')
    }, // Required. Cookie can be string or object, see the api refeence below
  lang: LanguageEnum.ENGLISH, // optional
})

Find out more reference in Zenless Zone Zero API Refence