Enka-network API wrapper for Genshin Impact.
npm install enka-network-apish-session
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.
`sh-session
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.
`js
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();
`
$3
You can update your genshin cache data.
`js
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.
`js
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
$3
EnkaClient#fetchUser
`js
const { EnkaClient } = require("enka-network-api");
const enka = new EnkaClient();
enka.fetchUser(825436941).then(user => {
console.log(user);
});
`
$3
EnkaClient#getAllCharacters
`js
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")));
`
$3
EnkaClient#getAllWeapons
`js
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")));
``