Skip to main content

enka-network-api

Enka.Network

npm versionnpm downloads

About

A Node.js Enka.Network API wrapper for Genshin Impact.

This is NOT the source code of Enka.Network or its API.

[!TIP] If you need a wrapper for Honkai: Star Rail, you can use starrail.js.

Features

  • User Data and Character Stats using EnkaNetwork.
  • All Characters and All Weapons Data. (Including More Advanced Info, such as Skill Attributes and Weapon Refinements.)
  • Cache Updater for the new update of Genshin Impact. (Update characters and weapons immediately.)
  • Honkai: Star Rail support with starrail.js integration. (See the example here.)

Installation

Node.js 16 or newer is required.

Install enka-network-api including genshin cache data.

npm install enka-network-api@latest
Install using ghproxy.com

npm install enka-network-api@latest --enka-ghproxy=true


If you have already moved the cache to another folder, you can also install without downloading the cache.

npm install enka-network-api@latest --enka-nocache=true

About Genshin Cache Data

Genshin cache data is from Dimbreath/AnimeGameData (gitlab).

This data contains data of characters, weapons, materials, and more structure information of Genshin Impact.

You can change your cache directory.

const { EnkaClient } = require("enka-network-api");

// Change the directory to store cache data.
// Default directory is node_modules/enka-network-api/cache.
const enka = new EnkaClient();
enka.cachedAssetsManager.cacheDirectoryPath = "./cache";
enka.cachedAssetsManager.cacheDirectorySetup();

// OR

const enka = new EnkaClient({ cacheDirectory: "./cache" });
enka.cachedAssetsManager.cacheDirectorySetup();

Updating

You can update your genshin cache data.

const { EnkaClient } = require("enka-network-api");
const enka = new EnkaClient({ showFetchCacheLog: true }); // showFetchCacheLog is true by default

enka.cachedAssetsManager.fetchAllContents(); // returns promise

Also, you can activate auto cache updater.

When using the auto-cache updater, we recommend moving the cache directory directly under your project folder.

const { EnkaClient } = require("enka-network-api");
const enka = new EnkaClient();

enka.cachedAssetsManager.activateAutoCacheUpdater({
instant: true, // Run the first update check immediately
timeout: 60 * 60 * 1000, // 1 hour interval
onUpdateStart: async () => {
console.log("Updating Genshin Data...");
},
onUpdateEnd: async () => {
enka.cachedAssetsManager.refreshAllData(); // Refresh memory
console.log("Updating Completed!");
}
});

// // deactivate
// enka.cachedAssetsManager.deactivateAutoCacheUpdater();

How to use

Fetching Player Data

EnkaClient#fetchUser

const { EnkaClient } = require("enka-network-api");
const enka = new EnkaClient();

enka.fetchUser(825436941).then(user => {
console.log(user);
});

Genshin Character List

EnkaClient#getAllCharacters

const { EnkaClient } = require("enka-network-api");
const enka = new EnkaClient();

const characters = enka.getAllCharacters();
// print character names in language "en"
console.log(characters.map(c => c.name.get("en")));

Genshin Weapon List

EnkaClient#getAllWeapons

const { EnkaClient } = require("enka-network-api");
const enka = new EnkaClient();

const weapons = enka.getAllWeapons();
// print weapon names in language "jp"
console.log(weapons.map(w => w.name.get("jp")));

More examples are available in example folder.

For more information, please check Documentation.

You can see the changelog here.

Index

Type Aliases

Arkhe

Arkhe: Pneuma | Ousia | Furina

BodyType

BodyType: BODY_MALE | BODY_BOY | BODY_LADY | BODY_GIRL | BODY_LOLI

CharacterKey

CharacterKey: string

CharacterRarity

CharacterRarity: QUALITY_ORANGE | QUALITY_PURPLE | QUALITY_ORANGE_SP

CharacterVoiceActors

CharacterVoiceActors: { [ lang in VoiceLanguage ]: TextAssets }

ElementType

ElementType: Wind | Rock | Electric | Grass | Water | Fire | Ice
ElementTypeIn-game Name
WindAnemo
RockGeo
ElectricElectro
GrassDendro
WaterHydro
FirePyro
IceCryo

EquipType

EquipType: EQUIP_BRACER | EQUIP_NECKLACE | EQUIP_SHOES | EQUIP_RING | EQUIP_DRESS
EquipTypeIn-game Name
EQUIP_BRACERFlower of Life
EQUIP_NECKLACEPlume of Death
EQUIP_SHOESSands of Eon
EQUIP_RINGGoblet of Eonothem
EQUIP_DRESSCirclet of Logos

FightProp

FightProp: FIGHT_PROP_BASE_HP | FIGHT_PROP_HP | FIGHT_PROP_HP_PERCENT | FIGHT_PROP_BASE_ATTACK | FIGHT_PROP_ATTACK | FIGHT_PROP_ATTACK_PERCENT | FIGHT_PROP_BASE_DEFENSE | FIGHT_PROP_DEFENSE | FIGHT_PROP_DEFENSE_PERCENT | FIGHT_PROP_BASE_SPEED | FIGHT_PROP_SPEED_PERCENT | FIGHT_PROP_CRITICAL | FIGHT_PROP_ANTI_CRITICAL | FIGHT_PROP_CRITICAL_HURT | FIGHT_PROP_ELEMENT_MASTERY | FIGHT_PROP_CHARGE_EFFICIENCY | FIGHT_PROP_ADD_HURT | FIGHT_PROP_SUB_HURT | FIGHT_PROP_HEAL_ADD | FIGHT_PROP_HEALED_ADD | FIGHT_PROP_FIRE_ADD_HURT | FIGHT_PROP_FIRE_SUB_HURT | FIGHT_PROP_WATER_ADD_HURT | FIGHT_PROP_WATER_SUB_HURT | FIGHT_PROP_GRASS_ADD_HURT | FIGHT_PROP_GRASS_SUB_HURT | FIGHT_PROP_ELEC_ADD_HURT | FIGHT_PROP_ELEC_SUB_HURT | FIGHT_PROP_ICE_ADD_HURT | FIGHT_PROP_ICE_SUB_HURT | FIGHT_PROP_WIND_ADD_HURT | FIGHT_PROP_WIND_SUB_HURT | FIGHT_PROP_PHYSICAL_ADD_HURT | FIGHT_PROP_PHYSICAL_SUB_HURT | FIGHT_PROP_ROCK_ADD_HURT | FIGHT_PROP_ROCK_SUB_HURT | FIGHT_PROP_MAX_HP | FIGHT_PROP_CUR_ATTACK | FIGHT_PROP_CUR_DEFENSE | FIGHT_PROP_CUR_SPEED | FIGHT_PROP_CUR_HP | FIGHT_PROP_SKILL_CD_MINUS_RATIO | FIGHT_PROP_SHIELD_COST_MINUS_RATIO
NameDescription
FIGHT_PROP_BASE_HPBase HP
FIGHT_PROP_HPFlat HP
FIGHT_PROP_HP_PERCENTHP%
FIGHT_PROP_BASE_ATTACKBase ATK
FIGHT_PROP_ATTACKFlat ATK
FIGHT_PROP_ATTACK_PERCENTATK%
FIGHT_PROP_BASE_DEFENSEBase DEF
FIGHT_PROP_DEFENSEFlat DEF
FIGHT_PROP_DEFENSE_PERCENTDEF%
FIGHT_PROP_BASE_SPEEDBase Speed
FIGHT_PROP_SPEED_PERCENTSpeed%
FIGHT_PROP_CRITICALCrit RATE
FIGHT_PROP_ANTI_CRITICALAnti Critical (Unknown)
FIGHT_PROP_CRITICAL_HURTCrit DMG
FIGHT_PROP_ELEMENT_MASTERYElemental Mastery
FIGHT_PROP_CHARGE_EFFICIENCYEnergy Recharge
FIGHT_PROP_ADD_HURTDMG Bonus
FIGHT_PROP_SUB_HURTDMG Reduction
FIGHT_PROP_HEAL_ADDHealing Bonus
FIGHT_PROP_HEALED_ADDIncoming Healing Bonus
FIGHT_PROP_FIRE_ADD_HURTPyro DMG Bonus
FIGHT_PROP_FIRE_SUB_HURTPyro RES
FIGHT_PROP_WATER_ADD_HURTHydro DMG Bonus
FIGHT_PROP_WATER_SUB_HURTHydro RES
FIGHT_PROP_GRASS_ADD_HURTDendro DMG Bonus
FIGHT_PROP_GRASS_SUB_HURTDendro RES
FIGHT_PROP_ELEC_ADD_HURTElectro DMG Bonus
FIGHT_PROP_ELEC_SUB_HURTElectro RES
FIGHT_PROP_ICE_ADD_HURTCryo DMG Bonus
FIGHT_PROP_ICE_SUB_HURTCryo RES
FIGHT_PROP_WIND_ADD_HURTAnemo DMG Bonus
FIGHT_PROP_WIND_SUB_HURTAnemo RES
FIGHT_PROP_PHYSICAL_ADD_HURTPhysical DMG Bonus
FIGHT_PROP_PHYSICAL_SUB_HURTPhysical RES
FIGHT_PROP_ROCK_ADD_HURTGeo DMG Bonus
FIGHT_PROP_ROCK_SUB_HURTGeo RES
FIGHT_PROP_MAX_HPMax HP
FIGHT_PROP_CUR_ATTACKCurrent ATK
FIGHT_PROP_CUR_DEFENSECurrent DEF
FIGHT_PROP_CUR_SPEEDCurrent Speed
FIGHT_PROP_CUR_HPCurrent HP
FIGHT_PROP_SKILL_CD_MINUS_RATIOCD Reduction
FIGHT_PROP_SHIELD_COST_MINUS_RATIOShield Strength

Gender

Gender: MALE | FEMALE

GenshinPlatform

GenshinPlatform: MOBILE | PC | PS

ItemType

ItemType: ITEM_VIRTUAL | ITEM_MATERIAL

LanguageCode

LanguageCode: chs | cht | de | en | es | fr | id | jp | kr | pt | ru | th | vi

LanguageMap

LanguageMap: { [ key in LanguageCode ]: {} }

MaterialKey

MaterialKey: string

NullableLanguageMap

NullableLanguageMap: { [ key in LanguageCode ]: {} | null }

Overwrite

Overwrite<T, U>: Omit<T, keyof U> & U

Type parameters

  • T
  • U: { [ Key in keyof T ]?: unknown }

Paths

Paths<T, D>: [D] extends [never] ? never : T extends object ? { [ K in keyof T ]-?: K extends string ? `${K}` | Join<K, Paths<T[K], Prev[D]>> : never }[keyof T] :

Type parameters

  • T
  • D: number = 10

ProfilePictureType

ProfilePictureType: PROFILE_PICTURE_UNLOCK_BY_AVATAR | PROFILE_PICTURE_UNLOCK_BY_COSTUME | PROFILE_PICTURE_UNLOCK_BY_ITEM

SetKey

SetKey: string

SlotKey

SlotKey: flower | plume | sands | goblet | circlet

StatKey

StatKey: hp | hp_ | atk | atk_ | def | def_ | eleMas | enerRech_ | heal_ | critRate_ | critDMG_ | physical_dmg_ | anemo_dmg_ | geo_dmg_ | electro_dmg_ | hydro_dmg_ | pyro_dmg_ | cryo_dmg_ | dendro_dmg_

VoiceLanguage

VoiceLanguage: chinese | japanese | english | korean

WeaponKey

WeaponKey: string

WeaponType

WeaponType: WEAPON_SWORD_ONE_HAND | WEAPON_CLAYMORE | WEAPON_POLE | WEAPON_CATALYST | WEAPON_BOW

Variables

constartifactSlotMap

artifactSlotMap: { EQUIP_BRACER: flower; EQUIP_DRESS: circlet; EQUIP_NECKLACE: plume; EQUIP_RING: goblet; EQUIP_SHOES: sands } = ...

Type declaration

  • readonlyEQUIP_BRACER: flower
  • readonlyEQUIP_DRESS: circlet
  • readonlyEQUIP_NECKLACE: plume
  • readonlyEQUIP_RING: goblet
  • readonlyEQUIP_SHOES: sands

constdefaultEnkaClientOptions

defaultEnkaClientOptions: Overwrite<EnkaClientOptions, { enkaSystem: EnkaSystem | null }> = ...

constdefaultImageBaseUrls

defaultImageBaseUrls: (ImageBaseUrl | CustomImageBaseUrl)[] = ...

constelementList

elementList: readonly [null, Fire, Water, Grass, Electric, Ice, null, Wind, Rock] = ...

constfightProps

fightProps: { 1: FIGHT_PROP_BASE_HP; 10: FIGHT_PROP_BASE_SPEED; 1010: FIGHT_PROP_CUR_HP; 11: FIGHT_PROP_SPEED_PERCENT; 2: FIGHT_PROP_HP; 20: FIGHT_PROP_CRITICAL; 2000: FIGHT_PROP_MAX_HP; 2001: FIGHT_PROP_CUR_ATTACK; 2002: FIGHT_PROP_CUR_DEFENSE; 2003: FIGHT_PROP_CUR_SPEED; 22: FIGHT_PROP_CRITICAL_HURT; 23: FIGHT_PROP_CHARGE_EFFICIENCY; 26: FIGHT_PROP_HEAL_ADD; 27: FIGHT_PROP_HEALED_ADD; 28: FIGHT_PROP_ELEMENT_MASTERY; 29: FIGHT_PROP_PHYSICAL_SUB_HURT; 3: FIGHT_PROP_HP_PERCENT; 30: FIGHT_PROP_PHYSICAL_ADD_HURT; 4: FIGHT_PROP_BASE_ATTACK; 40: FIGHT_PROP_FIRE_ADD_HURT; 41: FIGHT_PROP_ELEC_ADD_HURT; 42: FIGHT_PROP_WATER_ADD_HURT; 43: FIGHT_PROP_GRASS_ADD_HURT; 44: FIGHT_PROP_WIND_ADD_HURT; 45: FIGHT_PROP_ROCK_ADD_HURT; 46: FIGHT_PROP_ICE_ADD_HURT; 5: FIGHT_PROP_ATTACK; 50: FIGHT_PROP_FIRE_SUB_HURT; 51: FIGHT_PROP_ELEC_SUB_HURT; 52: FIGHT_PROP_WATER_SUB_HURT; 53: FIGHT_PROP_GRASS_SUB_HURT; 54: FIGHT_PROP_WIND_SUB_HURT; 55: FIGHT_PROP_ROCK_SUB_HURT; 56: FIGHT_PROP_ICE_SUB_HURT; 6: FIGHT_PROP_ATTACK_PERCENT; 7: FIGHT_PROP_BASE_DEFENSE; 8: FIGHT_PROP_DEFENSE; 80: FIGHT_PROP_SKILL_CD_MINUS_RATIO; 81: FIGHT_PROP_SHIELD_COST_MINUS_RATIO; 9: FIGHT_PROP_DEFENSE_PERCENT } = ...

Type declaration

  • readonly1: FIGHT_PROP_BASE_HP
  • readonly10: FIGHT_PROP_BASE_SPEED
  • readonly1010: FIGHT_PROP_CUR_HP
  • readonly11: FIGHT_PROP_SPEED_PERCENT
  • readonly2: FIGHT_PROP_HP
  • readonly20: FIGHT_PROP_CRITICAL
  • readonly2000: FIGHT_PROP_MAX_HP
  • readonly2001: FIGHT_PROP_CUR_ATTACK
  • readonly2002: FIGHT_PROP_CUR_DEFENSE
  • readonly2003: FIGHT_PROP_CUR_SPEED
  • readonly22: FIGHT_PROP_CRITICAL_HURT
  • readonly23: FIGHT_PROP_CHARGE_EFFICIENCY
  • readonly26: FIGHT_PROP_HEAL_ADD
  • readonly27: FIGHT_PROP_HEALED_ADD
  • readonly28: FIGHT_PROP_ELEMENT_MASTERY
  • readonly29: FIGHT_PROP_PHYSICAL_SUB_HURT
  • readonly3: FIGHT_PROP_HP_PERCENT
  • readonly30: FIGHT_PROP_PHYSICAL_ADD_HURT
  • readonly4: FIGHT_PROP_BASE_ATTACK
  • readonly40: FIGHT_PROP_FIRE_ADD_HURT
  • readonly41: FIGHT_PROP_ELEC_ADD_HURT
  • readonly42: FIGHT_PROP_WATER_ADD_HURT
  • readonly43: FIGHT_PROP_GRASS_ADD_HURT
  • readonly44: FIGHT_PROP_WIND_ADD_HURT
  • readonly45: FIGHT_PROP_ROCK_ADD_HURT
  • readonly46: FIGHT_PROP_ICE_ADD_HURT
  • readonly5: FIGHT_PROP_ATTACK
  • readonly50: FIGHT_PROP_FIRE_SUB_HURT
  • readonly51: FIGHT_PROP_ELEC_SUB_HURT
  • readonly52: FIGHT_PROP_WATER_SUB_HURT
  • readonly53: FIGHT_PROP_GRASS_SUB_HURT
  • readonly54: FIGHT_PROP_WIND_SUB_HURT
  • readonly55: FIGHT_PROP_ROCK_SUB_HURT
  • readonly56: FIGHT_PROP_ICE_SUB_HURT
  • readonly6: FIGHT_PROP_ATTACK_PERCENT
  • readonly7: FIGHT_PROP_BASE_DEFENSE
  • readonly8: FIGHT_PROP_DEFENSE
  • readonly80: FIGHT_PROP_SKILL_CD_MINUS_RATIO
  • readonly81: FIGHT_PROP_SHIELD_COST_MINUS_RATIO
  • readonly9: FIGHT_PROP_DEFENSE_PERCENT

constpercent

percent: readonly [FIGHT_PROP_HP_PERCENT, FIGHT_PROP_ATTACK_PERCENT, FIGHT_PROP_DEFENSE_PERCENT, FIGHT_PROP_SPEED_PERCENT, FIGHT_PROP_CRITICAL, FIGHT_PROP_CRITICAL_HURT, FIGHT_PROP_CHARGE_EFFICIENCY, FIGHT_PROP_HEAL_ADD, FIGHT_PROP_HEALED_ADD, FIGHT_PROP_PHYSICAL_SUB_HURT, FIGHT_PROP_PHYSICAL_ADD_HURT, FIGHT_PROP_FIRE_ADD_HURT, FIGHT_PROP_ELEC_ADD_HURT, FIGHT_PROP_WATER_ADD_HURT, FIGHT_PROP_GRASS_ADD_HURT, FIGHT_PROP_WIND_ADD_HURT, FIGHT_PROP_ROCK_ADD_HURT, FIGHT_PROP_ICE_ADD_HURT, FIGHT_PROP_FIRE_SUB_HURT, FIGHT_PROP_ELEC_SUB_HURT, FIGHT_PROP_WATER_SUB_HURT, FIGHT_PROP_GRASS_SUB_HURT, FIGHT_PROP_WIND_SUB_HURT, FIGHT_PROP_ROCK_SUB_HURT, FIGHT_PROP_ICE_SUB_HURT, FIGHT_PROP_SKILL_CD_MINUS_RATIO, FIGHT_PROP_SHIELD_COST_MINUS_RATIO] = ...

conststatKeyMap

statKeyMap: { anemo_dmg_: FIGHT_PROP_WIND_ADD_HURT; atk: FIGHT_PROP_ATTACK; atk_: FIGHT_PROP_ATTACK_PERCENT; critDMG_: FIGHT_PROP_CRITICAL_HURT; critRate_: FIGHT_PROP_CRITICAL; cryo_dmg_: FIGHT_PROP_ICE_ADD_HURT; def: FIGHT_PROP_DEFENSE; def_: FIGHT_PROP_DEFENSE_PERCENT; dendro_dmg_: FIGHT_PROP_GRASS_ADD_HURT; eleMas: FIGHT_PROP_ELEMENT_MASTERY; electro_dmg_: FIGHT_PROP_ELEC_ADD_HURT; enerRech_: FIGHT_PROP_CHARGE_EFFICIENCY; geo_dmg_: FIGHT_PROP_ROCK_ADD_HURT; heal_: FIGHT_PROP_HEAL_ADD; hp: FIGHT_PROP_HP; hp_: FIGHT_PROP_HP_PERCENT; hydro_dmg_: FIGHT_PROP_WATER_ADD_HURT; physical_dmg_: FIGHT_PROP_PHYSICAL_ADD_HURT; pyro_dmg_: FIGHT_PROP_FIRE_ADD_HURT } = ...

Type declaration

  • readonlyanemo_dmg_: FIGHT_PROP_WIND_ADD_HURT
  • readonlyatk: FIGHT_PROP_ATTACK
  • readonlyatk_: FIGHT_PROP_ATTACK_PERCENT
  • readonlycritDMG_: FIGHT_PROP_CRITICAL_HURT
  • readonlycritRate_: FIGHT_PROP_CRITICAL
  • readonlycryo_dmg_: FIGHT_PROP_ICE_ADD_HURT
  • readonlydef: FIGHT_PROP_DEFENSE
  • readonlydef_: FIGHT_PROP_DEFENSE_PERCENT
  • readonlydendro_dmg_: FIGHT_PROP_GRASS_ADD_HURT
  • readonlyeleMas: FIGHT_PROP_ELEMENT_MASTERY
  • readonlyelectro_dmg_: FIGHT_PROP_ELEC_ADD_HURT
  • readonlyenerRech_: FIGHT_PROP_CHARGE_EFFICIENCY
  • readonlygeo_dmg_: FIGHT_PROP_ROCK_ADD_HURT
  • readonlyheal_: FIGHT_PROP_HEAL_ADD
  • readonlyhp: FIGHT_PROP_HP
  • readonlyhp_: FIGHT_PROP_HP_PERCENT
  • readonlyhydro_dmg_: FIGHT_PROP_WATER_ADD_HURT
  • readonlyphysical_dmg_: FIGHT_PROP_PHYSICAL_ADD_HURT
  • readonlypyro_dmg_: FIGHT_PROP_FIRE_ADD_HURT

consttheaterDifficulties

theaterDifficulties: readonly [EASY, NORMAL, HARD, VISIONARY] = ...