An API wrapper for fetching player data of Genshin Impact from any servers.
# Via yarn
yarn add genshin-kit
# Or via npm
npm install genshin-kit
You can find some sample code snippets here.
Below is the documentation of GenshinKit.
Main methods
Instances of GenshinKit.
Returns: application instances of GenshinKit.
Constructor Example
const { GenshinKit } = require('genshin-kit')
const App = new GenshinKit()
Use cookies of hoyolab site to login to the instance.
⚠️ Caution⚠️ :Please keep your cookies safe.
NEVER SHARE YOUR COOKIES WITH ANYONE ELSE!
How to obtain: login to hoyolab Battle Chronicle https://webstatic-sea.mihoyo.com/app/community-game-records-sea/#/ys, then input document.cookie
in the browser console, it returns the cookies you need. Usually the cookies you obtained can be used for some time; if it fails, try to obtain another one.
Usage Example
App.loginWithCookie(process.env.MHY_COOKIE)
Set the server location of UID to be queried. Default is cn
; if you need to query Asia, Europe, US or HK-MC-TW server data, set this to os
.
cn
Chinese servers (Official, Bilibili)os
Oversea servers (Asia, Europe, US, HK-MC-TW)
Use UID to query player's basic information.
Returns: UserInfo
Request Example
App.getUserInfo(100000001).then(console.log)
Use UID to query player's detailed character information, including equipment.
Returns: Character[]
Use UID to query Spiral Abyss information.
type
: 1 means current Lunar Phase, 2 means previous Lunar Phase.
Returns: Abyss
Quick query: App.getCurrentAbyss(<uid:number>): Promise<Abyss>
App.getPreviousAbyss(<uid:number>): Promise<Abyss>
Get current activities score by uid.
Returns: Activities
Auxiliary utilities
const { util } = require('genshin-kit')
util.getTheActivedConstellationsNumberOfSpecifiedGenshinImpactCharacter(character: Character): number
get activated constellation number
Nah, just use util.activedConstellations
should be fine; this f**king long name originated when the author was discussing with his friends how to name this method.
Returns the activated constellation number of specified Genshin Impact character. (Sorry for copy paste this name again :)
A class encapsulating a set of methods for filtering character information.
Returns: Filter
class
Usage Example
const { CharactersFilter } = require('genshin-kit').util
App.getAllCharacters(100000001).then((data) => {
const Filter = new CharactersFilter(data)
// ...
}, console.error)
Get all characters for a specified player.
Get character information with specified id for a specified player.
Get character information with specified name for a specified player.
name
: character name, suggest in Simplified Chinese; also support aliases, see CharacterNickname
.
Get character information with specified element for a specified player.
element
: can be in English or Simplified Chinese, e.g. pyro
or 火
.
Get character information with specified rarity for a specified player.
rarity
: should be a number or a number array, e.g. 4
, 5
or [4, 5]
.
Expose the CharacterNickname
instance which the filter is using.
Returns: Nickname
class.
Add some nicknames to a character by its ID.
Get a character's ID by its nickname, maybe absent.
Get a character's nicknames by its ID, maybe absent.
Check whether input is a valid os uid.
For communication and learning only.
All game data & pictures from query: ©miHoYo
API endpoint: Refer Azure99/GenshinPlayerQuery (Apache-2.0 License)
Copyright 2021 Genshin-Kit
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at