npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

enka-network-api

v4.6.3

Published

Enka-network API wrapper for Genshin Impact.

Downloads

1,375

Readme

EnkaNetworkAPI

Enka.Network

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
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.