2022-06-22 06:14:31 +00:00
|
|
|
# Enka Network Python
|
2022-07-18 05:24:30 +00:00
|
|
|
EN | [TH](https://github.com/mrwan200/EnkaNetwork.py/blob/master/README_TH.md)
|
2022-07-05 06:35:54 +00:00
|
|
|
|
2022-07-17 18:51:53 +00:00
|
|
|
Library for API wrapper data from site https://enka.network/
|
2022-06-22 06:14:31 +00:00
|
|
|
|
2022-07-17 18:51:53 +00:00
|
|
|
# 🏓 Table of content
|
|
|
|
- [💾 Installation](#installation)
|
|
|
|
- [✨ Usage](#usage)
|
|
|
|
- [👀 Example](#example)
|
2022-07-18 05:24:30 +00:00
|
|
|
- [📗 Class Methods](#class-methods)
|
2022-07-17 18:51:53 +00:00
|
|
|
- [🚧 Structure](#structure)
|
|
|
|
- [Player](#player)
|
|
|
|
- [Namecard](#namecard)
|
|
|
|
- [Character preview](#character-preview)
|
|
|
|
- [Characters](#characters)
|
|
|
|
- [Icon](#icon)
|
|
|
|
- [Constellation](#constellation)
|
|
|
|
- [Skill](#skill)
|
|
|
|
- [Equipments (Artifact, Weapon)](#equipments-artifact-weapon)
|
|
|
|
- [Equipments Info](#equipments-info)
|
|
|
|
- [Equipments Stats](#equipments-stats)
|
|
|
|
- [FIGHT_PROP Data](#fight_prop-data)
|
|
|
|
- [🔧 Assets](#assets)
|
|
|
|
- [Character, constellations, skills, namecards](#assets-character-constellations-skills-namecards)
|
|
|
|
- [NameTextMapHash](#assets-nametextmaphash)
|
|
|
|
- [🌎 Languages Supported](#languages-supported)
|
|
|
|
- [📄 LICENSE](#license)
|
|
|
|
|
|
|
|
# Installation
|
2022-06-22 06:14:31 +00:00
|
|
|
```
|
2022-06-22 06:18:36 +00:00
|
|
|
pip install enkanetwork.py
|
2022-06-22 06:14:31 +00:00
|
|
|
```
|
|
|
|
|
2022-07-17 18:51:53 +00:00
|
|
|
# Usage
|
2022-06-22 06:14:31 +00:00
|
|
|
```py
|
|
|
|
import asyncio
|
|
|
|
|
|
|
|
from enkanetwork import EnkaNetworkAPI
|
|
|
|
|
|
|
|
client = EnkaNetworkAPI()
|
|
|
|
|
|
|
|
async def main():
|
|
|
|
data = await client.fetch_user(843715177)
|
2022-07-05 06:35:54 +00:00
|
|
|
print("=== Player Info ===")
|
2022-06-22 06:14:31 +00:00
|
|
|
print(f"Nickname: {data.player.nickname}")
|
|
|
|
print(f"Level: {data.player.level}")
|
2022-07-16 19:33:34 +00:00
|
|
|
print(f"Icon: {data.player.icon.url}")
|
2022-07-05 06:35:54 +00:00
|
|
|
print(f"Signature: {data.player.signature}")
|
|
|
|
print(f"Achievement: {data.player.achievement}")
|
|
|
|
print(f"Abyss floor: {data.player.abyss_floor} - {data.player.abyss_room}")
|
|
|
|
print(f"Cache timeout: {data.ttl}")
|
2022-06-22 06:14:31 +00:00
|
|
|
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
loop.run_until_complete(main())
|
|
|
|
```
|
2022-07-17 18:51:53 +00:00
|
|
|
## Preview
|
2022-06-22 06:14:31 +00:00
|
|
|
```sh
|
2022-07-05 06:35:54 +00:00
|
|
|
=== Player Info ===
|
2022-06-22 06:14:31 +00:00
|
|
|
Nickname: mrwan2546
|
|
|
|
Level: 55
|
2022-07-16 19:33:34 +00:00
|
|
|
Icon: https://enka.network/ui/UI_AvatarIcon_Kazuha.png
|
|
|
|
Signature: K A Z U H A M U C H <3
|
|
|
|
Achievement: 396
|
2022-07-05 06:35:54 +00:00
|
|
|
Abyss floor: 8 - 3
|
|
|
|
Cache timeout: 300
|
2022-06-22 06:14:31 +00:00
|
|
|
```
|
|
|
|
|
2022-07-17 18:51:53 +00:00
|
|
|
## Example
|
|
|
|
Please see in [example](./example/) folder.
|
|
|
|
|
2022-07-18 05:24:30 +00:00
|
|
|
# Class Methods
|
|
|
|
| Name | Description |
|
|
|
|
|------------|-----------------|
|
|
|
|
| fetch_user(uid) | Fetch user data |
|
|
|
|
| set_language(lang) | Set new language <br> Please see [Languages Supported](#languages-supported) |
|
|
|
|
| update_assets() | Update new assets from repo [Enkanetwork.py Data](https://github.com/mrwan200/enkanetwork.py-data/) |
|
|
|
|
|
2022-07-17 18:51:53 +00:00
|
|
|
# Structure
|
|
|
|
## Player
|
|
|
|
| Wrapper | API | Notes |
|
|
|
|
|-----------------|-----------------|-------------------|
|
|
|
|
| nickname | nickname | Please see [Namecard](#namecard) |
|
|
|
|
| signature | signature | |
|
|
|
|
| world_level | worldLevel | |
|
|
|
|
| achievement | finishAchievementNum | |
|
|
|
|
| namecard | namecardId | |
|
|
|
|
| namecards | showNameCardIdList -> id | Please see [Namecard](#namecard) |
|
|
|
|
| abyss_floor | towerFloorIndex | |
|
|
|
|
| abyss_room | towerLevelIndex | |
|
|
|
|
| characters_preview | showAvatarInfoList | Please see [Character Preview](#character-preview) |
|
|
|
|
| icon.url | profilePicture.avatarID | |
|
|
|
|
|
|
|
|
### Namecard
|
|
|
|
| Wrapper | API | Notes |
|
|
|
|
|-----------------|-----------------|-------------------|
|
|
|
|
| id | - | Namecard ID |
|
|
|
|
| name | - | Namecard name |
|
|
|
|
| icon | - | Namecard icon (url) |
|
|
|
|
| banner | - | Namecard banner (url) |
|
|
|
|
| navbar | - | Namecard navbar (Alpha) (url) |
|
|
|
|
|
|
|
|
### Character preview
|
|
|
|
| Wrapper | API | Notes |
|
|
|
|
|-----------------|-----------------|-------------------|
|
|
|
|
| id | - | Avatar ID |
|
|
|
|
| name | - | Avatar Name |
|
|
|
|
| level | - | Avatar Level |
|
|
|
|
| icon | - | Avatar Icon (url) |
|
|
|
|
|
|
|
|
## Characters
|
|
|
|
| Wrapper | API | Notes |
|
|
|
|
|-----------------|-----------------|-------------------|
|
|
|
|
| id | avatarId | |
|
|
|
|
| name | - | Avatar Name |
|
|
|
|
| element | - | Please see [Element Type](#element-type) |
|
|
|
|
| image | - | Please see [Icon](#icon) |
|
|
|
|
| xp | propMap -> 1001 | |
|
|
|
|
| ascension | propMap -> 1002 | |
|
|
|
|
| level | propMap -> 4001 | |
|
|
|
|
| max_level | - | Avatar max level (Like 50/60) |
|
|
|
|
| friendship_level| fetterInfo.level| |
|
|
|
|
| equipments | equipList | Please see [Equipments](#equipments-artifact-weapon) |
|
|
|
|
| stats | fightPropMap | Please see [FIGHT_PROP Data](#fight_prop-data) |
|
|
|
|
| constellations | talentIdList | Please see [Constellation](#constellation) |
|
|
|
|
| skill_data | inherentProudSkillList | |
|
|
|
|
| skill_id | skillDepotId | |
|
|
|
|
| skills | - | Please see [Skill](#skill) |
|
|
|
|
|
|
|
|
### Icon
|
|
|
|
| Wrapper | API | Notes |
|
|
|
|
|-----------------|-----------------|-------------------|
|
|
|
|
| icon | - | Avatar icon (url) |
|
|
|
|
| side | - | Avatar side icon (url) |
|
|
|
|
| banner | - | Avatar wish banner (url) |
|
|
|
|
|
|
|
|
### Constellation
|
|
|
|
| Wrapper | API | Notes |
|
|
|
|
|-----------------|-----------------|-------------------|
|
|
|
|
| id | - | Constellation ID |
|
|
|
|
| name | - | Constellation Name |
|
|
|
|
| icon | - | Constellation Icon (url) |
|
|
|
|
| unlocked | - | Constellation has unlocked |
|
|
|
|
|
|
|
|
### Skill
|
|
|
|
| Wrapper | API | Notes |
|
|
|
|
|-----------------|-----------------|-------------------|
|
|
|
|
| id | - | Skill ID |
|
|
|
|
| name | - | Skill Name |
|
|
|
|
| icon | - | Skill Icon (url) |
|
|
|
|
| level | - | Skill Level |
|
|
|
|
|
|
|
|
## Equipments (Artifact, Weapon)
|
|
|
|
| Wrapper | API | Notes |
|
|
|
|
|-----------------|-----------------|-------------------|
|
|
|
|
| id | itemId | |
|
|
|
|
| level | reliquary -> level, weapon -> level|
|
|
|
|
| type | - | Type of equipment (Artifact or Weapon) |
|
|
|
|
| refinement | weapon -> affixMap | |
|
|
|
|
| ascension | weapon -> promoteLevel | |
|
|
|
|
| detail | flat | Please see [Equipments Info](#equipments-info) |
|
|
|
|
|
|
|
|
### Equipments Info
|
|
|
|
| Wrapper | API | Notes |
|
|
|
|
|-----------------|-----------------|-------------------|
|
|
|
|
| name | - | Equipment Name (Artifact name or Weapon name) |
|
|
|
|
| icon | icon | |
|
|
|
|
| artifact_type | - | Please see [Artifact Type](#artifact-type) |
|
|
|
|
| rarity | rankLevel | |
|
|
|
|
| mainstats | reliquaryMainstat, weaponStats -> 0 | Please see [Equipments Stats](#equipments-stats) |
|
|
|
|
| substats | reliquarySubstats, weaponStats -> 1 | Please see [Equipments Stats](#equipments-stats) |
|
|
|
|
|
|
|
|
### Equipments Stats
|
|
|
|
| Wrapper | API | Notes |
|
|
|
|
|-----------------|-----------------|-------------------|
|
|
|
|
| prop_id | prop_id | |
|
|
|
|
| type | - | Value type (NUMBER or PERCENT) |
|
|
|
|
| name | - | Name of FIGHT_PROP|
|
|
|
|
| value | value | |
|
|
|
|
|
|
|
|
## FIGHT_PROP Data
|
|
|
|
|
|
|
|
In FIGHT_PROP data. You can get the value from 4 ways.
|
|
|
|
| Choice | Example | Output |
|
|
|
|
|------------------|---------------------------|----------------------------|
|
|
|
|
| Get raw value | stats.FIGHT_PROP_HP.value | 15552.306640625 |
|
|
|
|
| Get rounded value| stats.FIGHT_PROP_ATTACK.to_rounded() | 344 |
|
|
|
|
| Get percentage | stats.FIGHT_PROP_FIRE_ADD_HURT.to_percentage() | 61.5 |
|
|
|
|
| Get percentage and symbol | stats.FIGHT_PROP_FIRE_ADD_HURT.to_percentage_symbol() | 61.5% |
|
|
|
|
|
|
|
|
## Artifact Type
|
|
|
|
| Key | Value |
|
|
|
|
|---------------|---------------|
|
|
|
|
| Flower | EQUIP_BRACER |
|
|
|
|
| Feather | EQUIP_NECKLACE|
|
|
|
|
| Sands | EQUIP_SHOES |
|
|
|
|
| Goblet | EQUIP_RING |
|
|
|
|
| Circlet | EQUIP_DRESS |
|
|
|
|
|
|
|
|
## Element Type
|
|
|
|
| Key | Value |
|
|
|
|
|---------------|---------------|
|
2022-07-18 05:24:30 +00:00
|
|
|
| Cryo | Ice |
|
2022-07-17 18:51:53 +00:00
|
|
|
| Hydro | Water |
|
|
|
|
| Anemo | Wind |
|
|
|
|
| Pyro | Fire |
|
|
|
|
| Geo | Rock |
|
|
|
|
| Electro | Electric |
|
|
|
|
|
|
|
|
# Assets
|
|
|
|
|
|
|
|
## Assets character, constellations, skills, namecards
|
|
|
|
You can use avatarId to get the character, constellations, skills, namecards from assets.
|
|
|
|
```py
|
|
|
|
import asyncio
|
2022-07-05 06:35:54 +00:00
|
|
|
|
2022-07-17 18:51:53 +00:00
|
|
|
from enkanetwork import Assets
|
|
|
|
|
|
|
|
assets = Assets()
|
|
|
|
|
|
|
|
async def main():
|
|
|
|
# Character
|
|
|
|
assets.character(10000046)
|
|
|
|
# Constellations
|
|
|
|
assets.constellations(2081199193)
|
|
|
|
# Skills
|
|
|
|
assets.constellations(10462)
|
|
|
|
# Namecards
|
|
|
|
assets.namecards(210059)
|
|
|
|
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
loop.run_until_complete(main())
|
|
|
|
```
|
|
|
|
|
|
|
|
## Assets NameTextMapHash
|
2022-07-18 10:35:33 +00:00
|
|
|
The `NameTextMapHash` is a hash map that contains the name text of the assets. You can get `NameTextMapHash` from `hash_id` like this:
|
2022-07-17 18:51:53 +00:00
|
|
|
|
|
|
|
```py
|
|
|
|
import asyncio
|
|
|
|
|
|
|
|
from enkanetwork import Assets
|
|
|
|
|
2022-07-18 05:24:30 +00:00
|
|
|
assets = Assets(lang="en") # Set languege before get name (Ex. English)
|
2022-07-17 18:51:53 +00:00
|
|
|
|
|
|
|
async def main():
|
|
|
|
print(assets.get_hash_map(1940919994)) # Hu tao
|
|
|
|
# OR you can get FIGHT_PROP name
|
2022-07-18 05:24:30 +00:00
|
|
|
print(assets.get_hash_map("FIGHT_PROP_BASE_ATTACK")) # Base ATK
|
2022-07-17 18:51:53 +00:00
|
|
|
|
|
|
|
loop = asyncio.get_event_loop()
|
|
|
|
loop.run_until_complete(main())
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Languages Supported
|
2022-07-05 08:45:53 +00:00
|
|
|
| Languege | Code |
|
|
|
|
|-------------|---------|
|
|
|
|
| English | en |
|
2022-07-16 19:33:34 +00:00
|
|
|
| русский | ru |
|
2022-07-05 08:45:53 +00:00
|
|
|
| Tiếng Việt | vi |
|
|
|
|
| ไทย | th |
|
|
|
|
| português | pt |
|
|
|
|
| 한국어 | kr |
|
|
|
|
| 日本語 | jp |
|
|
|
|
| 中文 | zh |
|
|
|
|
| Indonesian | id |
|
|
|
|
| français | fr |
|
|
|
|
| español | es |
|
|
|
|
| deutsch | de |
|
|
|
|
| Taiwan | cht |
|
|
|
|
| Chinese | chs |
|
|
|
|
|
2022-07-17 18:51:53 +00:00
|
|
|
If you want full docs for the API, visit [EnkaNetwork API Docs](https://github.com/EnkaNetwork/API-docs)
|
2022-06-22 06:14:31 +00:00
|
|
|
|
2022-07-17 18:51:53 +00:00
|
|
|
# LICENSE
|
2022-06-22 06:14:31 +00:00
|
|
|
[MIT License](./LICENSE)
|
|
|
|
|
|
|
|
![Keqing](https://c.tenor.com/MnkpnVCLcb0AAAAC/keqing-dance.gif)
|
|
|
|
|
|
|
|
[Picture by KKOMDASTRO](https://twitter.com/KKOMDASTRO)
|