enka-network-api
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
const { EnkaClient } = require("enka-network-api");
const enka = new EnkaClient();
enka.fetchUser(825436941).then(user => {
console.log(user);
});
Genshin Character List
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
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
Classes
- Artifact
- ArtifactData
- ArtifactSet
- ArtifactSetBonus
- ArtifactSplitSubstat
- AssetsNotFoundError
- CachedAssetsManager
- Character
- CharacterAscension
- CharacterData
- CharacterDetails
- CharacterProfilePicture
- CharacterStats
- CharacterVoiceData
- Constellation
- Costume
- DetailedGenshinUser
- DynamicTextAssets
- Element
- ElementalBurst
- ElementalSkill
- EnkaClient
- GenshinCharacterBuild
- GenshinUser
- ImageAssets
- Material
- NameCard
- NormalAttack
- ObjectKeysManager
- PassiveTalent
- ProfilePicture
- Skill
- SkillAttributeAssets
- SkillLevel
- StatProperty
- TextAssets
- UniqueSkill
- UpgradableSkill
- UpgradeCost
- Weapon
- WeaponAscension
- WeaponData
- WeaponRefinement
Functions
Interfaces
Namespaces
Type Aliases
Variables
Type Aliases
BodyType
CharacterRarity
CharacterVoiceActors
ElementType
ElementType | In-game Name |
---|---|
Wind | Anemo |
Rock | Geo |
Electric | Electro |
Grass | Dendro |
Water | Hydro |
Fire | Pyro |
Ice | Cryo |
EquipType
EquipType | In-game Name |
---|---|
EQUIP_BRACER | Flower of Life |
EQUIP_NECKLACE | Plume of Death |
EQUIP_SHOES | Sands of Eon |
EQUIP_RING | Goblet of Eonothem |
EQUIP_DRESS | Circlet of Logos |
FightProp
Name | Description |
---|---|
FIGHT_PROP_BASE_HP | Base HP |
FIGHT_PROP_HP | Flat HP |
FIGHT_PROP_HP_PERCENT | HP% |
FIGHT_PROP_BASE_ATTACK | Base ATK |
FIGHT_PROP_ATTACK | Flat ATK |
FIGHT_PROP_ATTACK_PERCENT | ATK% |
FIGHT_PROP_BASE_DEFENSE | Base DEF |
FIGHT_PROP_DEFENSE | Flat DEF |
FIGHT_PROP_DEFENSE_PERCENT | DEF% |
FIGHT_PROP_BASE_SPEED | Base Speed |
FIGHT_PROP_SPEED_PERCENT | Speed% |
FIGHT_PROP_CRITICAL | Crit RATE |
FIGHT_PROP_ANTI_CRITICAL | Anti Critical (Unknown) |
FIGHT_PROP_CRITICAL_HURT | Crit DMG |
FIGHT_PROP_ELEMENT_MASTERY | Elemental Mastery |
FIGHT_PROP_CHARGE_EFFICIENCY | Energy Recharge |
FIGHT_PROP_ADD_HURT | DMG Bonus |
FIGHT_PROP_SUB_HURT | DMG Reduction |
FIGHT_PROP_HEAL_ADD | Healing Bonus |
FIGHT_PROP_HEALED_ADD | Incoming Healing Bonus |
FIGHT_PROP_FIRE_ADD_HURT | Pyro DMG Bonus |
FIGHT_PROP_FIRE_SUB_HURT | Pyro RES |
FIGHT_PROP_WATER_ADD_HURT | Hydro DMG Bonus |
FIGHT_PROP_WATER_SUB_HURT | Hydro RES |
FIGHT_PROP_GRASS_ADD_HURT | Dendro DMG Bonus |
FIGHT_PROP_GRASS_SUB_HURT | Dendro RES |
FIGHT_PROP_ELEC_ADD_HURT | Electro DMG Bonus |
FIGHT_PROP_ELEC_SUB_HURT | Electro RES |
FIGHT_PROP_ICE_ADD_HURT | Cryo DMG Bonus |
FIGHT_PROP_ICE_SUB_HURT | Cryo RES |
FIGHT_PROP_WIND_ADD_HURT | Anemo DMG Bonus |
FIGHT_PROP_WIND_SUB_HURT | Anemo RES |
FIGHT_PROP_PHYSICAL_ADD_HURT | Physical DMG Bonus |
FIGHT_PROP_PHYSICAL_SUB_HURT | Physical RES |
FIGHT_PROP_ROCK_ADD_HURT | Geo DMG Bonus |
FIGHT_PROP_ROCK_SUB_HURT | Geo RES |
FIGHT_PROP_MAX_HP | Max HP |
FIGHT_PROP_CUR_ATTACK | Current ATK |
FIGHT_PROP_CUR_DEFENSE | Current DEF |
FIGHT_PROP_CUR_SPEED | Current Speed |
FIGHT_PROP_CUR_HP | Current HP |
FIGHT_PROP_SKILL_CD_MINUS_RATIO | CD Reduction |
FIGHT_PROP_SHIELD_COST_MINUS_RATIO | Shield Strength |
Gender
GenshinPlatform
ItemType
LanguageCode
LanguageMap
NullableLanguageMap
Paths
Type parameters
- T
- D: number = 10
ProfilePictureType
VoiceLanguage
WeaponType
Variables
constartifactRarityRangeMap
Rarity map for artifact sets
Type declaration
readonly10001: readonly [3, 4]
readonly10002: readonly [3, 4]
readonly10003: readonly [3, 4]
readonly10004: readonly [3, 4]
readonly10005: readonly [3, 4]
readonly10006: readonly [3, 4]
readonly10007: readonly [3, 4]
readonly10008: readonly [3, 4]
readonly10009: readonly [3, 4]
readonly10010: readonly [1, 3]
readonly10011: readonly [1, 3]
readonly10012: readonly [3, 4]
readonly10013: readonly [1, 3]
readonly15009: readonly [3, 4]
readonly15010: readonly [3, 4]
readonly15011: readonly [3, 4]
readonly15013: readonly [3, 4]
constdefaultEnkaClientOptions
constfightProps
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