diff --git a/README.md b/README.md
index 3375e42..9cf740d 100644
--- a/README.md
+++ b/README.md
@@ -9,10 +9,9 @@
-
-## Soon...
\ No newline at end of file
+## 📦 Download
+
+- **используя `npm`**
+ ```shell
+ npm i enkanetwork
+ ```
+- **используя `Yarn`**
+ ```shell
+ yarn add enkanetwork
+ ```
+# 🛠️ Usage
+
+```js
+const { enkaNetwork } = require("enkanetwork"); //import { enkaNetwork } from "enkanetwork";
+const enka = new enkaNetwork({language: "EN"});
+```
+
+| Key | In API | Type | Description | Required? |
+| --------- | ------ | ------ | -------------------------------------------------------------------------------------------------------------- | ------------ |
+| language | - | number | The language to be used in the localization of names (characters, artifacts, etc.). Default is «EN» | - |
+
+```js
+const user = await enka.fetchUser(700832641);
+```
+
+| Key | In API | Type | Description | Required? |
+| --------- | ------ | ------ | ------------------------ | ------------ |
+| UID | - | number | `UID` from the game | + |
+# ⚙ Response structure
+
+## FetchUser
+
+| Key | In API | Type | Description |
+| --------- | ---------- | ------ | ------------------------------ |
+| player | playerInfo | object | See [Player](#player) |
+| characters | avatarInfoList | array | See [Characters](#characters) |
+| ttl | ttl | number | Cache lifetime in milliseconds |
+
+## Player
+
+| Key | In API | Type | Description |
+| ----------------- | -------------------- | ------ | ------------------------------------------------ |
+| nickname | nickname | string | Profile nickname |
+| signature | signature | string | Profile description |
+| level | level | number | User rank level |
+| worldLevel | worldLevel | number | User world level |
+| nameCard | - | object | See [NameCard](#namecard) |
+| achievements | finishAchievementNum | number | Achievements count |
+| abyssFloor | towerFloorIndex | number | The floor of the abyss passed by the player |
+| abyssLevel | towerLevelIndex | number | The hall of the abyss floor passed by the player |
+| charactersPreview | showAvatarInfoList | array | See [CharacterPreview](#characterpreview) |
+| nameCardsPreview | showNameCardIdList | array | See [NameCard](#namecard) |
+| profilePicture | profilePicture | object | See [ProfilePicture](#profilepicture) |
+
+### NameCard
+
+| Key | In API | Type | Description |
+| --------- | ---------- | ------ | ------------------------------ |
+| id | nameCardId | number | Namecard id |
+| name | - | string | Localized namecard name |
+| icon | - | string | URL to get the icon |
+| banner | - | string | URL to get the icon banner |
+| navbar | - | string | URL to get the icon navbar |
+
+### CharacterPreview
+
+| Key | In API | Type | Description |
+| --------- | ---------- | ------ | ------------------------------ |
+| id | avatarId | number | Character id |
+| name | - | string | Localized character name |
+| icon | - | string | URL to get the character icon |
+| level | level | number | Character level |
+
+### ProfilePicture
+
+| Key | In API | Type | Description |
+| --------- | ---------- | ------ | ------------------------------ |
+| id | avatarId | number | Character id |
+| name | - | string | Localized character name |
+| icon | - | string | URL to get the character icon |
+
+## Characters
+
+| Key | In API | Type | Description |
+| ----------------- | ---------------------- | ------ | ----------------------------------------------------- |
+| id | avatarId | number | Character id |
+| name | - | string | Localized character name |
+| icons | - | object | See [Icons](#icons) |
+| rarity | - | number | Character rarity (5 or 4) |
+| element | - | string | See [ElementType](#elementtype) |
+| level | propMap["4001"] | number | Character level |
+| elevations | propMap["1002"] | number | Character elevations |
+| xp | propMap["1001"] | number | Character expiriance |
+| constellation | talents | array | See [CharacterConstellation](#characterconstellation) |
+| skills | skills | array | See [CharacterSkill](#characterskill) |
+| skillSetId | skillDepotId | number | Character Skill Set ID |
+| skillData | inherentProudSkillList | array | List of Unlocked Skill Ids |
+| stats | fightPropMap | array | Character stats |
+| weapon | equipList | number | See [CharacterWeapon](#characterweapon) |
+| reluquary | equipList | number | See [ProfilePicture](#profilepicture) |
+
+### Icons
+
+| Key | In API | Type | Description |
+| --------- | ---------- | ------ | ------------------------------ |
+| avatar | - | string | Character avatar icon |
+| side | - | string | Character side avatar icon |
+
+### ElementType
+| Key | In API |
+| -------------- | -------------- |
+| Cryo | Ice |
+| Hydro | Water |
+| Anemo | Wind |
+| Pyro | Fire |
+| Geo | Rock |
+| Electro | Electric |
+
+### CharacterConstellation
+
+| Key | In API | Type | Description |
+| --------- | -------------- | ------- | -------------------------------------------- |
+| id | talent | number | Character constellation id |
+| name | - | string | Character constellation name |
+| icon | - | string | URL to get the character constellation icon |
+| unlocked | - | boolean | Character constellation unlocked? |
+
+### CharacterSkill
+
+| Key | In API | Type | Description |
+| --------- | -------------- | ------- | -------------------------------------------- |
+| id | skill | number | Character skill id |
+| name | - | string | Character skill name |
+| icon | - | string | URL to get the character skill icon |
+| level | level | number | Character skill level |
+
+### CharacterWeapon
+
+| Key | In API | Type | Description |
+| ----------- | ------------------- | ------- | -------------------------------------------- |
+| id | itemId | number | Character weapon id |
+| name | - | string | Character weapon name |
+| icon | - | string | URL to get the character weapon icon |
+| level | level | number | Character weapon level |
+| elevations | weapon.promoteLevel | number | Character weapon elevations |
+| improvement | weapon.affixMap | number | Character weapon improvement |
+| rarity | flat.rankLevel | number | Character weapon rarity |
+| mainStat | flat.weaponStats[0] | object | Character weapon main stat |
+| subStat | flat.weaponStats[1] | object | Character weapon sub stat |
+
+### CharacterReluquary
+
+| Key | In API | Type | Description |
+| ----------- | ---------------------- | ------- | -------------------------------------------- |
+| id | itemId | number | Character reluquary id |
+| name | - | string | Character reluquary name |
+| setName | - | string | Character reluquary set name |
+| icon | - | string | URL to get the character reluquary icon |
+| type | - | string | See [ReliquaryType](#characterreluquary) |
+| level | reliquary.level | number | Character reluquary level |
+| rarity | flat.rankLevel | number | Character reluquary rarity |
+| mainStat | flat.reliquaryMainstat | object | Character reluquary main stat |
+| subStat | flat.reliquarySubstats | object | Character reluquary sub stat |
+
+### ReliquaryType
+
+| Key | In API |
+| -------------- | -------------- |
+| Flower | EQUIP_BRACER |
+| Feather | EQUIP_NECKLACE |
+| Sands | EQUIP_SHOES |
+| Goblet | EQUIP_RING |
+| Circlet | EQUIP_DRESS |
+
+For assets thanks [enkanetwork.py-data](https://github.com/mrwan200/enkanetwork.py-data/)
\ No newline at end of file
diff --git a/assets/logo.png b/assets/logo.png
index d8932be..d2a4b9a 100644
Binary files a/assets/logo.png and b/assets/logo.png differ
diff --git a/dist/models/character.d.ts b/dist/models/character.d.ts
index 24f8dc3..6dcd54d 100644
--- a/dist/models/character.d.ts
+++ b/dist/models/character.d.ts
@@ -11,19 +11,19 @@ export declare class character {
element: string;
elevations: number;
xp: number;
- constellation: characterConstellation[];
stats: characterStats;
- skills: characterSkills[];
+ constellation: characterConstellation[];
+ skills: characterSkill[];
skillSetId: number;
skillData: number[];
- weapon: any;
- reluquary: characterReluquary;
+ weapon: characterWeapon;
+ reluquary: characterReluquary[];
constructor(lang: string, character: any);
}
export declare class characterReluquary {
id: number;
level: number;
- raity: number;
+ rarity: number;
mainStats: {
appendPropId: string;
statValue: number;
@@ -43,12 +43,12 @@ export declare class characterWeapon {
level: number;
elevations: number;
improvement: number;
- raity: number;
+ rarity: number;
mainStat: {
appendPropId: string;
statValue: number;
};
- subStat: {
+ subStat?: {
appendPropId: string;
statValue: number;
};
@@ -63,7 +63,7 @@ export declare class characterConstellation {
unlocked: boolean;
constructor(lang: string, talent: number, talents: number[]);
}
-export declare class characterSkills {
+export declare class characterSkill {
id: number;
icon: string;
name: string;
diff --git a/dist/models/character.js b/dist/models/character.js
index 075e24e..f6bc788 100644
--- a/dist/models/character.js
+++ b/dist/models/character.js
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
-exports.characterStats = exports.characterSkills = exports.characterConstellation = exports.characterWeapon = exports.characterReluquary = exports.character = void 0;
+exports.characterStats = exports.characterSkill = exports.characterConstellation = exports.characterWeapon = exports.characterReluquary = exports.character = void 0;
const getAssetUrl_1 = require("../helpers/getAssetUrl");
const getNormalElement_1 = require("../helpers/getNormalElement");
// @ts-ignore: Json Import
@@ -47,7 +47,7 @@ class character {
this.reluquary = character.equipList.filter((x) => x.reliquary).map((reliquary) => new characterReluquary(lang, reliquary));
this.stats = new characterStats(character.fightPropMap);
this.constellation = characterAsset.talents.map((talent) => { return new characterConstellation(lang, talent, (character === null || character === void 0 ? void 0 : character.talentIdList) || []); });
- this.skills = characterAsset.skills.map((skill) => { return new characterSkills(lang, skill, (character === null || character === void 0 ? void 0 : character.skillLevelMap[skill]) || 0); });
+ this.skills = characterAsset.skills.map((skill) => { return new characterSkill(lang, skill, (character === null || character === void 0 ? void 0 : character.skillLevelMap[skill]) || 0); });
this.skillSetId = character.skillDepotId;
this.skillData = character.inherentProudSkillList;
this.level = Number(((_a = character.propMap["4001"]) === null || _a === void 0 ? void 0 : _a.ival) || 0);
@@ -72,7 +72,7 @@ class characterReluquary {
this.icon = (0, getAssetUrl_1.getAssetUrl)(equipment.flat.icon);
this.type = reluquaryTypes[equipment.flat.equipType];
this.level = --equipment.reliquary.level;
- this.raity = equipment.flat.rankLevel;
+ this.rarity = equipment.flat.rankLevel;
this.mainStats = equipment.flat.reliquaryMainstat;
this.subStats = equipment.flat.reliquarySubstats;
}
@@ -84,11 +84,11 @@ class characterWeapon {
this.name = charactersWeaponLocalizations[equipment.flat.nameTextMapHash][lang];
this.icon = (0, getAssetUrl_1.getAssetUrl)(equipment.flat.icon);
this.level = equipment.weapon.level;
- this.elevations = equipment.weapon.promoteLevel;
- this.improvement = equipment.weapon.affixMap[Object.keys(equipment.weapon.affixMap)[0]] + 1;
- this.raity = equipment.flat.rankLevel;
+ this.elevations = equipment.weapon.promoteLevel || 0;
+ this.improvement = equipment.weapon.affixMap ? equipment.weapon.affixMap[Object.keys(equipment.weapon.affixMap)[0]] + 1 : 1;
+ this.rarity = equipment.flat.rankLevel;
this.mainStat = equipment.flat.weaponStats[0];
- this.subStat = equipment.flat.weaponStats[1];
+ this.subStat = equipment.flat.weaponStats[1] || false;
}
}
exports.characterWeapon = characterWeapon;
@@ -103,7 +103,7 @@ class characterConstellation {
}
}
exports.characterConstellation = characterConstellation;
-class characterSkills {
+class characterSkill {
constructor(lang, skill, level) {
const charactersSkillsAsset = charactersSkillsAssets[skill];
const charactersSkillsLocalization = charactersSkillsLocalizations[charactersSkillsAsset.nameTextMapHash];
@@ -113,7 +113,7 @@ class characterSkills {
this.level = level;
}
}
-exports.characterSkills = characterSkills;
+exports.characterSkill = characterSkill;
class characterStats {
constructor(stats) {
this.BASE_HP = stats["1"] || 0;
diff --git a/dist/models/fetchUser.d.ts b/dist/models/fetchUser.d.ts
index 0649b7a..d9d8270 100644
--- a/dist/models/fetchUser.d.ts
+++ b/dist/models/fetchUser.d.ts
@@ -2,7 +2,7 @@ import { IPlayerInfo } from "../types/index";
import { playerInfo } from "./playerInfo";
import { character } from "./character";
export declare class fetchUser {
- playerInfo: playerInfo;
+ player: playerInfo;
characters: character[];
ttl: number;
constructor(language: string, data: {
diff --git a/dist/models/fetchUser.js b/dist/models/fetchUser.js
index c894218..845a5a4 100644
--- a/dist/models/fetchUser.js
+++ b/dist/models/fetchUser.js
@@ -5,7 +5,7 @@ const playerInfo_1 = require("./playerInfo");
const character_1 = require("./character");
class fetchUser {
constructor(language, data) {
- this.playerInfo = new playerInfo_1.playerInfo(language, data.playerInfo);
+ this.player = new playerInfo_1.playerInfo(language, data.playerInfo);
this.characters = data.avatarInfoList.map(avatar => { return new character_1.character(language, avatar); });
this.ttl = data.ttl;
}
diff --git a/dist/models/playerInfo.d.ts b/dist/models/playerInfo.d.ts
index 624c6b1..e78c1d7 100644
--- a/dist/models/playerInfo.d.ts
+++ b/dist/models/playerInfo.d.ts
@@ -7,14 +7,12 @@ export declare class playerInfo {
signature: string;
level: number;
worldLevel: number;
- nameCardId: number;
nameCard: nameCard;
- finishAchievementNum: number;
- towerFloorIndex: number;
- towerLevelIndex: number;
+ achievements: number;
+ abyssFloor: number;
+ abyssLevel: number;
charactersPreview: characterPreview[];
nameCardsPreview: nameCard[];
- showNameCardIdList: number[];
profilePicture: profilePicture;
constructor(language: string, data: IPlayerInfo);
}
diff --git a/dist/models/playerInfo.js b/dist/models/playerInfo.js
index 28c546a..3a0f3a5 100644
--- a/dist/models/playerInfo.js
+++ b/dist/models/playerInfo.js
@@ -11,9 +11,9 @@ class playerInfo {
this.level = data.level;
this.worldLevel = data.worldLevel;
this.nameCard = new nameCard_1.nameCard(language, data.nameCardId);
- this.finishAchievementNum = data.finishAchievementNum;
- this.towerFloorIndex = data.towerFloorIndex;
- this.towerLevelIndex = data.towerLevelIndex;
+ this.achievements = data.finishAchievementNum;
+ this.abyssFloor = data.towerFloorIndex;
+ this.abyssLevel = data.towerLevelIndex;
this.charactersPreview = data.showAvatarInfoList.map((character) => {
return new characterPreview_1.characterPreview(language, character);
});
diff --git a/dist/types/index.d.ts b/dist/types/index.d.ts
index 15b484a..1ba9a5a 100644
--- a/dist/types/index.d.ts
+++ b/dist/types/index.d.ts
@@ -54,10 +54,10 @@ export interface ICharacterConstellationAsset {
nameTextMapHash: number;
icon: string;
}
-export interface ICharacterSkillsAssets {
- [key: string]: ICharacterSkillsAsset;
+export interface ICharacterSkillAssets {
+ [key: string]: ICharacterSkillAsset;
}
-export interface ICharacterSkillsAsset {
+export interface ICharacterSkillAsset {
nameTextMapHash: number;
skillIcon: string;
}
diff --git a/src/models/character.ts b/src/models/character.ts
index c4ee541..efa726a 100644
--- a/src/models/character.ts
+++ b/src/models/character.ts
@@ -1,4 +1,4 @@
-import { ICharacterAssets, ICharacterConstellationAssets, ICharacterSkillsAssets, ILocalizations } from "../types/index";
+import { ICharacterAssets, ICharacterConstellationAssets, ICharacterSkillAssets, ILocalizations } from "../types/index";
import { getAssetUrl } from "../helpers/getAssetUrl";
import { getNormalElement } from "../helpers/getNormalElement";
// @ts-ignore: Json Import
@@ -24,7 +24,7 @@ const charactersAssets: ICharacterAssets = CharactersAssets;
const charactersLocalizations: ILocalizations = CharactersLocalizations;
const charactersConstellationAssets: ICharacterConstellationAssets = CharactersConstellationAssets;
const charactersConstellationLocalizations: ILocalizations = CharactersConstellationLocalizations;
-const charactersSkillsAssets: ICharacterSkillsAssets = CharactersSkillsAssets;
+const charactersSkillsAssets: ICharacterSkillAssets = CharactersSkillsAssets;
const charactersSkillsLocalizations: ILocalizations = CharactersSkillsLocalizations;
const charactersWeaponLocalizations: ILocalizations = CharactersWeaponLocalizations;
const charactersReluquaryLocalizations: ILocalizations = CharactersReluquaryLocalizations;
@@ -40,13 +40,13 @@ export class character {
element: string;
elevations: number;
xp: number;
- constellation: characterConstellation[];
stats: characterStats;
- skills: characterSkills[];
+ constellation: characterConstellation[];
+ skills: characterSkill[];
skillSetId: number;
skillData: number[];
- weapon: any;
- reluquary: characterReluquary;
+ weapon: characterWeapon;
+ reluquary: characterReluquary[];
constructor(lang: string, character: any) {
const characterAsset = charactersAssets[character.avatarId];
const characterLocalization = charactersLocalizations[characterAsset.nameTextMapHash];
@@ -59,7 +59,7 @@ export class character {
this.reluquary = character.equipList.filter((x: { reliquary: any; }) => x.reliquary).map((reliquary: any) => new characterReluquary(lang, reliquary));
this.stats = new characterStats(character.fightPropMap);
this.constellation = characterAsset.talents.map((talent) => { return new characterConstellation(lang, talent, character?.talentIdList || []); });
- this.skills = characterAsset.skills.map((skill) => { return new characterSkills(lang, skill, character?.skillLevelMap[skill] || 0); });
+ this.skills = characterAsset.skills.map((skill) => { return new characterSkill(lang, skill, character?.skillLevelMap[skill] || 0); });
this.skillSetId = character.skillDepotId;
this.skillData = character.inherentProudSkillList;
this.level = Number(character.propMap["4001"]?.ival || 0);
@@ -78,7 +78,7 @@ const reluquaryTypes: { [key: string]: string } = {
export class characterReluquary {
id: number;
level: number;
- raity: number;
+ rarity: number;
mainStats: { appendPropId: string, statValue: number };
subStats: { appendPropId: string, statValue: number }[];
icon: string;
@@ -92,7 +92,7 @@ export class characterReluquary {
this.icon = getAssetUrl(equipment.flat.icon);
this.type = reluquaryTypes[equipment.flat.equipType]
this.level = --equipment.reliquary.level;
- this.raity = equipment.flat.rankLevel;
+ this.rarity = equipment.flat.rankLevel;
this.mainStats = equipment.flat.reliquaryMainstat;
this.subStats = equipment.flat.reliquarySubstats;
}
@@ -102,9 +102,9 @@ export class characterWeapon {
level: number;
elevations: number;
improvement: number;
- raity: number;
+ rarity: number;
mainStat: { appendPropId: string, statValue: number };
- subStat: { appendPropId: string, statValue: number };
+ subStat?: { appendPropId: string, statValue: number };
icon: string;
name: string;
constructor(lang: string, equipment: any) {
@@ -112,11 +112,11 @@ export class characterWeapon {
this.name = charactersWeaponLocalizations[equipment.flat.nameTextMapHash][lang];
this.icon = getAssetUrl(equipment.flat.icon);
this.level = equipment.weapon.level;
- this.elevations = equipment.weapon.promoteLevel;
- this.improvement = equipment.weapon.affixMap[Object.keys(equipment.weapon.affixMap)[0]] + 1;
- this.raity = equipment.flat.rankLevel;
+ this.elevations = equipment.weapon.promoteLevel || 0;
+ this.improvement = equipment.weapon.affixMap ? equipment.weapon.affixMap[Object.keys(equipment.weapon.affixMap)[0]] + 1 : 1;
+ this.rarity = equipment.flat.rankLevel;
this.mainStat = equipment.flat.weaponStats[0];
- this.subStat = equipment.flat.weaponStats[1];
+ this.subStat = equipment.flat.weaponStats[1] || false;
}
}
export class characterConstellation {
@@ -133,7 +133,7 @@ export class characterConstellation {
this.unlocked = talents.includes(talent)
}
}
-export class characterSkills {
+export class characterSkill {
id: number;
icon: string;
name: string;
diff --git a/src/models/fetchUser.ts b/src/models/fetchUser.ts
index a5c557c..1d792cc 100644
--- a/src/models/fetchUser.ts
+++ b/src/models/fetchUser.ts
@@ -2,13 +2,13 @@ import { IPlayerInfo } from "../types/index";
import { playerInfo } from "./playerInfo";
import { character } from "./character";
export class fetchUser {
- playerInfo: playerInfo;
+ player: playerInfo;
characters: character[];
ttl: number;
constructor(language: string, data: {
avatarInfoList: string[]; playerInfo: IPlayerInfo; ttl: number;
}) {
- this.playerInfo = new playerInfo(language, data.playerInfo);
+ this.player = new playerInfo(language, data.playerInfo);
this.characters = data.avatarInfoList.map(avatar => { return new character(language, avatar); });
this.ttl = data.ttl;
}
diff --git a/src/models/playerInfo.ts b/src/models/playerInfo.ts
index d41a9fd..e92f81e 100644
--- a/src/models/playerInfo.ts
+++ b/src/models/playerInfo.ts
@@ -7,14 +7,12 @@ export class playerInfo {
signature: string;
level: number;
worldLevel: number;
- nameCardId!: number;
nameCard: nameCard;
- finishAchievementNum: number;
- towerFloorIndex: number;
- towerLevelIndex: number;
+ achievements: number;
+ abyssFloor: number;
+ abyssLevel: number;
charactersPreview: characterPreview[];
nameCardsPreview: nameCard[];
- showNameCardIdList!: number[];
profilePicture: profilePicture;
constructor(language: string, data: IPlayerInfo) {
this.nickname = data.nickname;
@@ -22,9 +20,9 @@ export class playerInfo {
this.level = data.level;
this.worldLevel = data.worldLevel;
this.nameCard = new nameCard(language, data.nameCardId);
- this.finishAchievementNum = data.finishAchievementNum;
- this.towerFloorIndex = data.towerFloorIndex;
- this.towerLevelIndex = data.towerLevelIndex;
+ this.achievements = data.finishAchievementNum;
+ this.abyssFloor = data.towerFloorIndex;
+ this.abyssLevel = data.towerLevelIndex;
this.charactersPreview = data.showAvatarInfoList.map((character: { avatarId: number, level: number }) => {
return new characterPreview(language, character);
});
diff --git a/src/types/index.ts b/src/types/index.ts
index 415309a..fd6cf9a 100644
--- a/src/types/index.ts
+++ b/src/types/index.ts
@@ -55,10 +55,10 @@ export interface ICharacterConstellationAsset {
nameTextMapHash: number;
icon: string;
}
-export interface ICharacterSkillsAssets {
- [key: string]: ICharacterSkillsAsset
+export interface ICharacterSkillAssets {
+ [key: string]: ICharacterSkillAsset
}
-export interface ICharacterSkillsAsset {
+export interface ICharacterSkillAsset {
nameTextMapHash: number;
skillIcon: string;
}
diff --git a/test.mjs b/test.mjs
index 8f8239f..4566291 100644
--- a/test.mjs
+++ b/test.mjs
@@ -1,6 +1,6 @@
import { enkaNetwork } from "./dist/index.js";
const enka = new enkaNetwork({language: "RU"});
const user = await enka.fetchUser(700832641);
-console.log(user);
-console.log(user.characters, user.characters[0].reluquary[0]);
-console.log("У юзера на аве стоит", user.playerInfo.profilePicture.name);
\ No newline at end of file
+console.log(user.characters[0].weapon);
+// console.log(user.characters);
+console.log("У юзера на аве стоит", user.player.profilePicture.name);
\ No newline at end of file