starrail.js
About
A Node.js Enka.Network/MiHoMo API wrapper for Honkai: Star Rail.
Features
- User Data and Character Stats by UID with Enka.Network API (or with MiHoMo API).
- All Characters and All Light Cones Data.
- Cache Updater for the new update of Honkai: Star Rail. (Update characters and light cones immediately.)
Installation
Node.js 16 or newer is required.
Install starrail.js including Star Rail cache data.
npm install starrail.js@latest
Install using ghproxy.com
npm install starrail.js@latest --sr-ghproxy=true
If you have already moved the cache to another folder, you can also install without downloading the cache.
npm install starrail.js@latest --sr-nocache=true
About Star Rail Cache Data
Star Rail cache data is from Dimbreath/StarRailData
This data contains data of characters, light cones, materials, and more structure information of Star Rail.
You can change your cache directory.
const { StarRail } = require("starrail.js");
// Change the directory to store cache data.
// Default directory is node_modules/starrail.js/cache.
const client = new StarRail();
client.cachedAssetsManager.cacheDirectoryPath = "./cache";
client.cachedAssetsManager.cacheDirectorySetup();
// OR
const client = new StarRail({ cacheDirectory: "./cache" });
client.cachedAssetsManager.cacheDirectorySetup();
Updating
You can update your Star Rail cache data.
const { StarRail } = require("starrail.js");
const client = new StarRail({ showFetchCacheLog: true }); // showFetchCacheLog is true by default
client.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 { StarRail } = require("starrail.js");
const client = new StarRail();
client.cachedAssetsManager.activateAutoCacheUpdater({
instant: true, // Run the first update check immediately
timeout: 60 * 60 * 1000, // 1 hour interval
onUpdateStart: async () => {
console.log("Updating Star Rail Data...");
},
onUpdateEnd: async () => {
client.cachedAssetsManager.refreshAllData(); // Refresh memory
console.log("Updating Completed!");
}
});
// // deactivate
// client.cachedAssetsManager.deactivateAutoCacheUpdater();
How to use
Fetching Player Data
const { StarRail } = require("starrail.js");
const client = new StarRail();
client.fetchUser(800069903).then(user => {
console.log(user);
});
Star Rail Character List
const { StarRail } = require("starrail.js");
const client = new StarRail();
const characters = client.getAllCharacters();
// print character names in language "en"
console.log(characters.map(c => c.name.get("en")));
Star Rail Light Cone List
const { StarRail } = require("starrail.js");
const client = new StarRail();
const lightCones = client.getAllLightCones();
// print light cone names in language "jp"
console.log(lightCones.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
- AssetsNotFoundError
- CachedAssetsManager
- Character
- CharacterData
- CharacterStats
- CombatType
- DynamicTextAssets
- Eidolon
- ImageAssets
- LeveledSkill
- LeveledSkillTreeNode
- LightCone
- LightConeData
- LightConeExpType
- LightConeSuperimposition
- ObjectKeysManager
- OverallStatList
- Path
- Relic
- RelicData
- RelicExpType
- RelicMainStat
- RelicMainStatGroup
- RelicSet
- RelicSetBonus
- RelicSubStat
- RelicSubStatGroup
- RelicType
- Skill
- SkillLevel
- SkillTreeNode
- StarRail
- StarRailCharacterBuild
- StarRailUser
- StatList
- StatProperty
- StatPropertyValue
- TextAssets
- TextUtils
- UserIcon
Functions
Interfaces
Type Aliases
Variables
Type Aliases
CombatTypeId
CombatTypeId | In-game Name |
---|---|
Physical | Physical |
Fire | Fire |
Ice | Ice |
Thunder | Lightning |
Wind | Wind |
Quantum | Quantum |
Imaginary | Imaginary |
EffectType
ExcelDataMap
ExcelKey
ExcelType
IndexBy
Type parameters
- T
- Keys: (string | number)[]
LanguageCode
LanguageMap
LoadedExcelDataMap
LoadedLanguageMap
OtherStatPropertyType
StatPropertyTypes which do not exist in AvatarPropertyConfig.json
OtherStatPropertyType | isPercent | defaultValue | Comment |
---|---|---|---|
SpeedAddedRatio | true | 0 |
Overwrite
Type parameters
- T
- U: { [ Key in keyof T ]?: unknown }
PathId
PathId | In-game Name |
---|---|
Warrior | Destruction |
Rogue | The Hunt |
Mage | Erudition |
Shaman | Harmony |
Warlock | Nihility |
Knight | Preservation |
Priest | Abundance |
Platform
RelicTypeId
RelicTypeId | In-game Name |
---|---|
HEAD | Head |
HAND | Hands |
BODY | Body |
FOOT | Feet |
OBJECT | Link Rope |
NECK | Planar Sphere |
SimpleMap
Type parameters
- K
- V
SimpleObject
Type parameters
- T = never
Type declaration
[key string]: SimpleObject<T> | T
SingleBy
Type parameters
- Keys: ExcelKey[]
SkillType
StatPropertyType
StatPropertyType | isPercent | defaultValue | Comment |
---|---|---|---|
MaxHP | false | 0 | |
Attack | false | 0 | |
Defence | false | 0 | |
Speed | false | 0 | |
CriticalChance | true | 0 | unknown, but used, likely percent |
CriticalDamage | true | 0 | unknown, but used, likely percent |
BreakDamageAddedRatio | true | 0 | unknown, not used, likely percent |
BreakDamageAddedRatioBase | true | 0 | |
HealRatio | true | 0 | unknown, not used, likely percent |
MaxSP | false | 0 | |
SPRatio | true | 0 | unknown, not used, likely percent |
StatusProbability | true | 0 | unknown, only used in inventory sort, likely percent |
StatusResistance | true | 0 | unknown, only used in inventory sort, likely percent |
CriticalChanceBase | true | 0 | |
CriticalDamageBase | true | 0 | |
HealRatioBase | true | 0 | |
StanceBreakAddedRatio | true | 0 | unknown, not used, likely percent |
SPRatioBase | true | 1 | |
StatusProbabilityBase | true | 0 | |
StatusResistanceBase | true | 0 | |
PhysicalAddedRatio | true | 0 | |
PhysicalResistance | true | 0 | |
FireAddedRatio | true | 0 | |
FireResistance | true | 0 | |
IceAddedRatio | true | 0 | |
IceResistance | true | 0 | |
ThunderAddedRatio | true | 0 | |
ThunderResistance | true | 0 | |
WindAddedRatio | true | 0 | |
WindResistance | true | 0 | |
QuantumAddedRatio | true | 0 | |
QuantumResistance | true | 0 | |
ImaginaryAddedRatio | true | 0 | |
ImaginaryResistance | true | 0 | |
BaseHP | false | 0 | |
HPDelta | false | 0 | |
HPAddedRatio | true | 0 | |
BaseAttack | false | 0 | |
AttackDelta | false | 0 | |
AttackAddedRatio | true | 0 | |
BaseDefence | false | 0 | |
DefenceDelta | false | 0 | |
DefenceAddedRatio | true | 0 | |
BaseSpeed | false | 0 | |
HealTakenRatio | true | 0 | unknown, not used, likely percent |
PhysicalResistanceDelta | false | 0 | unknown, not used, likely flat |
FireResistanceDelta | false | 0 | unknown, not used, likely flat |
IceResistanceDelta | false | 0 | unknown, not used, likely flat |
ThunderResistanceDelta | false | 0 | unknown, not used, likely flat |
WindResistanceDelta | false | 0 | unknown, not used, likely flat |
QuantumResistanceDelta | false | 0 | unknown, not used, likely flat |
ImaginaryResistanceDelta | false | 0 | unknown, not used, likely flat |
SpeedDelta | false | 0 |
Variables
constcombatTypeIconColors
constdefaultClientOption
constexcelKeyMap
Type declaration
readonlyAvatarBaseType: readonly [readonly [ID, Unknown]]
readonlyAvatarConfig: readonly [AvatarID]
readonlyAvatarPlayerIcon: readonly [ID]
readonlyAvatarPromotionConfig: readonly [AvatarID, readonly [Promotion, 0]]
readonlyAvatarPropertyConfig: readonly [PropertyType]
readonlyAvatarRankConfig: readonly [RankID]
readonlyAvatarSkillConfig: readonly [SkillID, Level]
readonlyAvatarSkillTreeConfig: readonly [PointID, Level]
readonlyDamageType: readonly [ID]
readonlyEquipmentConfig: readonly [EquipmentID]
readonlyEquipmentExpType: readonly [ExpType, Level]
readonlyEquipmentPromotionConfig: readonly [EquipmentID, readonly [Promotion, 0]]
readonlyEquipmentSkillConfig: readonly [SkillID, Level]
readonlyItemConfigAvatar: readonly [ID]
readonlyItemConfigAvatarPlayerIcon: readonly [ID]
readonlyItemConfigEquipment: readonly [ID]
readonlyItemConfigRelic: readonly [ID]
readonlyItemPlayerCard: readonly [ID]
readonlyPlayerIcon: readonly [ID]
readonlyRelicBaseType: readonly [readonly [Type, All]]
readonlyRelicConfig: readonly [ID]
readonlyRelicExpType: readonly [TypeID, readonly [Level, 0]]
readonlyRelicMainAffixConfig: readonly [GroupID, AffixID]
readonlyRelicSetConfig: readonly [SetID]
readonlyRelicSetSkillConfig: readonly [SetID, RequireNum]
readonlyRelicSubAffixConfig: readonly [GroupID, AffixID]
constexcels
constotherStatPropertyTypes
Type declaration
readonlySpeedAddedRatio: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
constpathMap
Type declaration
readonlyKnight: Preservation
readonlyMage: Erudition
readonlyPriest: Abundance
readonlyRogue: The Hunt
readonlyShaman: Harmony
readonlyUnknown: General
readonlyWarlock: Nihility
readonlyWarrior: Destruction
constplatformMap
Type declaration
[key number]: Platform
conststatPropertyTypes
Type declaration
readonlyAttack: { defaultValue: 0; isPercent: false }
readonlydefaultValue: 0
readonlyisPercent: false
readonlyAttackAddedRatio: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyAttackDelta: { defaultValue: 0; isPercent: false }
readonlydefaultValue: 0
readonlyisPercent: false
readonlyBaseAttack: { defaultValue: 0; isPercent: false }
readonlydefaultValue: 0
readonlyisPercent: false
readonlyBaseDefence: { defaultValue: 0; isPercent: false }
readonlydefaultValue: 0
readonlyisPercent: false
readonlyBaseHP: { defaultValue: 0; isPercent: false }
readonlydefaultValue: 0
readonlyisPercent: false
readonlyBaseSpeed: { defaultValue: 0; isPercent: false }
readonlydefaultValue: 0
readonlyisPercent: false
readonlyBreakDamageAddedRatio: { comment: unknown, not used, likely percent; defaultValue: 0; isPercent: true }
readonlycomment: unknown, not used, likely percent
readonlydefaultValue: 0
readonlyisPercent: true
readonlyBreakDamageAddedRatioBase: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyCriticalChance: { comment: unknown, but used, likely percent; defaultValue: 0; isPercent: true }
readonlycomment: unknown, but used, likely percent
readonlydefaultValue: 0
readonlyisPercent: true
readonlyCriticalChanceBase: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyCriticalDamage: { comment: unknown, but used, likely percent; defaultValue: 0; isPercent: true }
readonlycomment: unknown, but used, likely percent
readonlydefaultValue: 0
readonlyisPercent: true
readonlyCriticalDamageBase: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyDefence: { defaultValue: 0; isPercent: false }
readonlydefaultValue: 0
readonlyisPercent: false
readonlyDefenceAddedRatio: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyDefenceDelta: { defaultValue: 0; isPercent: false }
readonlydefaultValue: 0
readonlyisPercent: false
readonlyFireAddedRatio: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyFireResistance: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyFireResistanceDelta: { comment: unknown, not used, likely flat; defaultValue: 0; isPercent: false }
readonlycomment: unknown, not used, likely flat
readonlydefaultValue: 0
readonlyisPercent: false
readonlyHPAddedRatio: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyHPDelta: { defaultValue: 0; isPercent: false }
readonlydefaultValue: 0
readonlyisPercent: false
readonlyHealRatio: { comment: unknown, not used, likely percent; defaultValue: 0; isPercent: true }
readonlycomment: unknown, not used, likely percent
readonlydefaultValue: 0
readonlyisPercent: true
readonlyHealRatioBase: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyHealTakenRatio: { comment: unknown, not used, likely percent; defaultValue: 0; isPercent: true }
readonlycomment: unknown, not used, likely percent
readonlydefaultValue: 0
readonlyisPercent: true
readonlyIceAddedRatio: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyIceResistance: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyIceResistanceDelta: { comment: unknown, not used, likely flat; defaultValue: 0; isPercent: false }
readonlycomment: unknown, not used, likely flat
readonlydefaultValue: 0
readonlyisPercent: false
readonlyImaginaryAddedRatio: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyImaginaryResistance: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyImaginaryResistanceDelta: { comment: unknown, not used, likely flat; defaultValue: 0; isPercent: false }
readonlycomment: unknown, not used, likely flat
readonlydefaultValue: 0
readonlyisPercent: false
readonlyMaxHP: { defaultValue: 0; isPercent: false }
readonlydefaultValue: 0
readonlyisPercent: false
readonlyMaxSP: { defaultValue: 0; isPercent: false }
readonlydefaultValue: 0
readonlyisPercent: false
readonlyPhysicalAddedRatio: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyPhysicalResistance: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyPhysicalResistanceDelta: { comment: unknown, not used, likely flat; defaultValue: 0; isPercent: false }
readonlycomment: unknown, not used, likely flat
readonlydefaultValue: 0
readonlyisPercent: false
readonlyQuantumAddedRatio: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyQuantumResistance: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyQuantumResistanceDelta: { comment: unknown, not used, likely flat; defaultValue: 0; isPercent: false }
readonlycomment: unknown, not used, likely flat
readonlydefaultValue: 0
readonlyisPercent: false
readonlySPRatio: { comment: unknown, not used, likely percent; defaultValue: 0; isPercent: true }
readonlycomment: unknown, not used, likely percent
readonlydefaultValue: 0
readonlyisPercent: true
readonlySPRatioBase: { defaultValue: 1; isPercent: true }
readonlydefaultValue: 1
readonlyisPercent: true
readonlySpeed: { defaultValue: 0; isPercent: false }
readonlydefaultValue: 0
readonlyisPercent: false
readonlySpeedDelta: { defaultValue: 0; isPercent: false }
readonlydefaultValue: 0
readonlyisPercent: false
readonlyStanceBreakAddedRatio: { comment: unknown, not used, likely percent; defaultValue: 0; isPercent: true }
readonlycomment: unknown, not used, likely percent
readonlydefaultValue: 0
readonlyisPercent: true
readonlyStatusProbability: { comment: unknown, only used in inventory sort, likely percent; defaultValue: 0; isPercent: true }
readonlycomment: unknown, only used in inventory sort, likely percent
readonlydefaultValue: 0
readonlyisPercent: true
readonlyStatusProbabilityBase: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyStatusResistance: { comment: unknown, only used in inventory sort, likely percent; defaultValue: 0; isPercent: true }
readonlycomment: unknown, only used in inventory sort, likely percent
readonlydefaultValue: 0
readonlyisPercent: true
readonlyStatusResistanceBase: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyThunderAddedRatio: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyThunderResistance: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyThunderResistanceDelta: { comment: unknown, not used, likely flat; defaultValue: 0; isPercent: false }
readonlycomment: unknown, not used, likely flat
readonlydefaultValue: 0
readonlyisPercent: false
readonlyWindAddedRatio: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyWindResistance: { defaultValue: 0; isPercent: true }
readonlydefaultValue: 0
readonlyisPercent: true
readonlyWindResistanceDelta: { comment: unknown, not used, likely flat; defaultValue: 0; isPercent: false }
readonlycomment: unknown, not used, likely flat
readonlydefaultValue: 0
readonlyisPercent: false