Coder Social home page Coder Social logo

pwnless / enka.py Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 3.0 372 KB

Friendly python wrapper for fetching genshin impact user data from https://enka.network/

Home Page: http://enkapy.rtfd.io/

License: MIT License

Python 100.00%
genshin-api genshin-impact enka-network enkanetwork mihoyo python enka

enka.py's Introduction

Enka.py

Downloads Downloads Documentation Status

Friendly API for fetching genshin user data from https://enka.shinshin.moe/ (Now https://enka.network)

Added name parsing and full artifact support and more elegant code.

original from https://github.com/mrwan200/EnkaNetwork.py, but better!

Documentation

see http://enkapy.rtfd.io/

Installation

pip install enka.py

Usage

import asyncio

from enkapy import Enka

client = Enka()


async def main():
    await client.load_lang()
    user = await client.fetch_user(104267816)
    print(f"Nickname: {user.player.nickname}")
    print(f"Level: {user.player.level}")
    print(f'Signature: {user.player.signature}')
    print(f'World level:{user.player.worldLevel}')
    print(f'Abyss: {user.player.towerFloorIndex}-{user.player.towerLevelIndex}')
    # fetch first character
    if user.characters:
        character = user.characters[0]
        print(f'Name: {character.name}')
        print(f'Ascension: {character.ascension}')
        print(f'Level: {character.level}')
        print(f'Exp: {character.experience}')
        print('Weapon:')
        weapon = character.weapon
        print(f'\tName: {weapon.name}')
        print(f'\tLevel: {weapon.level}')
        print(f'\tRefine: {weapon.refine}')
        print(f'\tStar level: {weapon.rank}')
    
        print('Constellations:')
        for constellation in character.constellations:
            if constellation.activated:
                print(f'\t{constellation.name} Activated')
        print('Skills:')
        for skill in character.skills:
            if skill.type == 0:
                print(f'\tNormal skill {skill.name}, level:{skill.level}')
            elif skill.type == 1:
                print(f'\tElemental skill {skill.name}, level:{skill.level}')
            elif skill.type == 2:
                print(f'\tElemental burst {skill.name}, level:{skill.level}')
        print('Artifacts:')
        for artifact in character.artifacts:
            print(f'\t{artifact.set_name} {artifact.name}:')
            print(f'\t{artifact.main_stat.prop}:{artifact.main_stat.value}')
            for sub_stats in artifact.sub_stats:
                print(f'\t\t{sub_stats.prop}:{sub_stats.value}')


loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Result:

Nickname: 天天向上
Level: 60
Signature: 凌人有点无脑
World level:8
Abyss: 12-3
Name: Kamisato Ayaka
Ascension: 6
Level: 90
Exp: 0
Weapon:
    Name: Mistsplitter Reforged
    Level: 90
    Refine: 5
    Star level: 5
Constellations:
    Snowswept Sakura Activated
    Blizzard Blade Seki no To Activated
    Frostbloom Kamifubuki Activated
    Ebb and Flow Activated
    Blossom Cloud Irutsuki Activated
    Dance of Suigetsu Activated
Skills:
    Elemental burst Kamisato Art: Soumetsu, level:10
    Normal skill Normal Attack: Kamisato Art - Kabuki, level:10
    Elemental skill Kamisato Art: Hyouka, level:9
    Normal skill Kamisato Art: Senho, level:1
Artifacts:
    Blizzard Strayer Snowswept Memory:
    FIGHT_PROP_HP:4780.0
        FIGHT_PROP_ELEMENT_MASTERY:44.0
        FIGHT_PROP_CRITICAL_HURT:38.1
        FIGHT_PROP_DEFENSE:16.0
        FIGHT_PROP_CRITICAL:3.9
    Blizzard Strayer Icebreaker's Resolve:
    FIGHT_PROP_ATTACK:311.0
        FIGHT_PROP_CRITICAL:3.1
        FIGHT_PROP_ELEMENT_MASTERY:35.0
        FIGHT_PROP_CHARGE_EFFICIENCY:10.4
        FIGHT_PROP_CRITICAL_HURT:21.8
    Blizzard Strayer Frozen Homeland's Demise:
    FIGHT_PROP_ATTACK_PERCENT:46.6
        FIGHT_PROP_HP_PERCENT:8.7
        FIGHT_PROP_ATTACK:18.0
        FIGHT_PROP_CRITICAL_HURT:13.2
        FIGHT_PROP_CRITICAL:10.5
    Archaic Petra Goblet of Chiseled Crag:
    FIGHT_PROP_ICE_ADD_HURT:46.6
        FIGHT_PROP_ELEMENT_MASTERY:16.0
        FIGHT_PROP_CRITICAL_HURT:25.7
        FIGHT_PROP_HP_PERCENT:10.5
        FIGHT_PROP_CRITICAL:5.4
    Blizzard Strayer Broken Rime's Echo:
    FIGHT_PROP_CRITICAL_HURT:62.2
        FIGHT_PROP_CRITICAL:11.7
        FIGHT_PROP_ATTACK_PERCENT:9.3
        FIGHT_PROP_ELEMENT_MASTERY:42.0
        FIGHT_PROP_DEFENSE:35.0

If you want full docs for the API, visit EnkaNetwork API

LICENSE

MIT License

enka.py's People

Contributors

nitolar avatar pwnless avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

enka.py's Issues

how can i get Japanese name?

I changed "await client.load_lang()" in this code section to "await client.load_lang(lang='jp') and executed the code, but I could not get it in Japanese Properly.
How can i get it in Japanese?

i use python 3.12.1 in Windows10, VS Code 1.85.1, and ver. 1.2.1 enka.py.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.