enkanetwork
v3.1.1
Published
API wrapper for enka.network written on TypeScript which provides localization, caching and convenience
Maintainers
Readme
enkaNetwork
Node JS enka.network API wrapper written on TypeScript which provides
auto-updated assets, localization, caching and convenience.
📦 Download
usage
npmnpm install enkanetwork --languages=ENusage
yarnyarn add enkanetwork --languages=ENusage
pnpmpnpm install enkanetwork --languages=ENusage
bunbun install enkanetwork --languages=EN
🎮 Game support
This wrapper currently supports Genshin Impact only. enka.network also serves
Honkai: Star Rail (/hsr/uid/), Zenless Zone Zero (/zzz/uid/) and Arknights: Endfield,
but those endpoints are not implemented here. The bundled game data is sourced from
Dimbreath/AnimeGameData (master branch,
ExcelBinOutput/ + TextMap/), the canonical Genshin datamine.
🖼️ Image assets & CDNs
Every icon URL is produced by a pluggable asset adapter. By default icons resolve to
https://enka.network/ui/{icon}.png.
[!NOTE] enka.network only hosts images that are actually used on the site, so a freshly released icon may
404. In that case point the adapter at another CDN.
All of these mirror the same internal UI_* filenames from the game data, so only the
prefix (and extension) change — no custom code needed:
| CDN | baseUrl | extension |
| --- | --- | --- |
| enka.network (default) | https://enka.network/ui/ | .png |
| Hakush.in | https://static.nanoka.cc/gi/UI/ | .webp |
| Project Amber | https://gi.yatta.moe/assets/UI/ | .png |
import { EnkaNetwork, OriginAdapter, FileSystemAdapter } from "enkanetwork";
// Use a different CDN (e.g. Hakush.in / webp)
new EnkaNetwork({
assetAdapter: new OriginAdapter({
baseUrl: "https://static.nanoka.cc/gi/UI/",
extension: ".webp",
}),
});
// Cache icons to the local filesystem (lazy download, origin fallback)
new EnkaNetwork({
assetAdapter: new FileSystemAdapter({ directory: "./.enka-cache/ui" }),
});
// Already have a complete local mirror? Just point at it:
new EnkaNetwork({
assetAdapter: new OriginAdapter({ baseUrl: "/root/guoba/assets/ui/" }),
});
// Bring your own: anything implementing `{ resolve(filename): string }`
new EnkaNetwork({
assetAdapter: { resolve: (file) => `https://my.cdn/${file}.webp` },
});The legacy uiAssetsPath option still works (it builds an OriginAdapter for you).
Warm the cache after a fetch so every referenced icon (incl. weapon.awakenIcon and the
gacha/costume splash exposed as icons.gacha) lands on disk:
const user = await enka.fetchUser(uid);
await enka.assets.warm(); // awaits all pending downloads[!WARNING]
FileSystemAdapteronly caches the filenames the library returns. Prefer the exposed fields (weapon.awakenIcon,icons.gacha) over string-deriving names likeicon.replace(".png", "_Awaken.png")— derived names never pass through the cache. For renderers that need guaranteed-local paths, usefallbackToOrigin: false+warm(), or point anOriginAdapterat a complete local mirror. The HoYoverse in-game CDN uses hashed paths (notUI_*names), so it needs a custom adapter, not abaseUrlswap.
