genshinstats-api


Namegenshinstats-api JSON
Version 1.1 PyPI version JSON
download
home_pagehttps://github.com/thesadru/genshinstats-api
Summarya wrapper for the official hoyolab.com Genshin impact gameRecord API.
upload_time2021-02-23 17:04:46
maintainer
docs_urlNone
authorthesadru
requires_python>=3.6
license
keywords wrapper-api genshin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # genshin stats api
This project is meant to be a wrapper for the [hoyolab.com](https://www.hoyolab.com/genshin/) gameRecord api.
I have attempted to reverse engineer their API to find out the important tokens and cookies and then to what urls they are sent.
You can pip install with [PyPI](https://pypi.org/project/genshinstats-api/)

# how to use
Import the `genshin_stats` module and do `set_cookie(...)` to login.
You can either use `set_cookie(account_id=..., cookie_token=...)`.
The cookie is required and will raise an error if missing.
All functions are documented and type hinted.
## example
Simple example of usage:
```py
import genshinstats as gs # import module
gs.set_cookie(account_id=8366222, cookie_token="zHbPk8BO3FG4hEOFD2aO6ZlGR1vF75ipuTmFyi2w") # login
result = gs.search('sadru') # search a community user
uid = gs.get_uid_from_community(result['users'][1]['uid']) # get the uid fro the results
user_info = gs.get_user_info(uid) # get user info with the uid
total_characters = len(user_info['avatars']) # get the list of characters, called avatars in the basic API
print('user "sadru" has a total of',total_characters,'characters')
```
> the cookie token in this example is not valid, you must use your own.
## prettifiers
There are prettifier functions that turn data into a pretty version.
This is to rename some fields that don't make sense, like fetters.
These are highly recommended.
```py
characters = gs.prettify_characters(gs.get_all_characters(uid))
for char in characters:
    print(f"{char['rarity']}* {char['name']:10} Level: {char['level']} C{char['constellation']}")
```

# how to get your cookie
1. go to [hoyolab.com](https://www.hoyolab.com/genshin/)
2. login to your account
3. open inspect mode (Developer Tools)
4. go to `Application`, `Cookies`, `https://www.hoyolab.com`.
5. copy `account_id` and `cookie_token`
6. use `set_cookie(account_id=..., cookie_token=...)` in your code

# about this project
## contribution
All contributions are welcome as long as it's in a form of a clean PR.
## crediting
This project can be freely downloaded and distributed.
Crediting is appreciated.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/thesadru/genshinstats-api",
    "name": "genshinstats-api",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "wrapper-api,genshin",
    "author": "thesadru",
    "author_email": "dan0.suman@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f7/c6/dca57afc2d5a337a2288867cea01035dd50eca6900dcbb71005a444a10c8/genshinstats-api-1.1.tar.gz",
    "platform": "",
    "description": "# genshin stats api\nThis project is meant to be a wrapper for the [hoyolab.com](https://www.hoyolab.com/genshin/) gameRecord api.\nI have attempted to reverse engineer their API to find out the important tokens and cookies and then to what urls they are sent.\nYou can pip install with [PyPI](https://pypi.org/project/genshinstats-api/)\n\n# how to use\nImport the `genshin_stats` module and do `set_cookie(...)` to login.\nYou can either use `set_cookie(account_id=..., cookie_token=...)`.\nThe cookie is required and will raise an error if missing.\nAll functions are documented and type hinted.\n## example\nSimple example of usage:\n```py\nimport genshinstats as gs # import module\ngs.set_cookie(account_id=8366222, cookie_token=\"zHbPk8BO3FG4hEOFD2aO6ZlGR1vF75ipuTmFyi2w\") # login\nresult = gs.search('sadru') # search a community user\nuid = gs.get_uid_from_community(result['users'][1]['uid']) # get the uid fro the results\nuser_info = gs.get_user_info(uid) # get user info with the uid\ntotal_characters = len(user_info['avatars']) # get the list of characters, called avatars in the basic API\nprint('user \"sadru\" has a total of',total_characters,'characters')\n```\n> the cookie token in this example is not valid, you must use your own.\n## prettifiers\nThere are prettifier functions that turn data into a pretty version.\nThis is to rename some fields that don't make sense, like fetters.\nThese are highly recommended.\n```py\ncharacters = gs.prettify_characters(gs.get_all_characters(uid))\nfor char in characters:\n    print(f\"{char['rarity']}* {char['name']:10} Level: {char['level']} C{char['constellation']}\")\n```\n\n# how to get your cookie\n1. go to [hoyolab.com](https://www.hoyolab.com/genshin/)\n2. login to your account\n3. open inspect mode (Developer Tools)\n4. go to `Application`, `Cookies`, `https://www.hoyolab.com`.\n5. copy `account_id` and `cookie_token`\n6. use `set_cookie(account_id=..., cookie_token=...)` in your code\n\n# about this project\n## contribution\nAll contributions are welcome as long as it's in a form of a clean PR.\n## crediting\nThis project can be freely downloaded and distributed.\nCrediting is appreciated.",
    "bugtrack_url": null,
    "license": "",
    "summary": "a wrapper for the official hoyolab.com Genshin impact gameRecord API.",
    "version": "1.1",
    "split_keywords": [
        "wrapper-api",
        "genshin"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "1a81abadab458a6667afed60909bc2a4",
                "sha256": "4265afe888e582d984a8eb2277ee1ebeda634e34a59a87e6e93f3e26a9e41c87"
            },
            "downloads": -1,
            "filename": "genshinstats-api-1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "1a81abadab458a6667afed60909bc2a4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 7197,
            "upload_time": "2021-02-23T17:04:46",
            "upload_time_iso_8601": "2021-02-23T17:04:46.657041Z",
            "url": "https://files.pythonhosted.org/packages/f7/c6/dca57afc2d5a337a2288867cea01035dd50eca6900dcbb71005a444a10c8/genshinstats-api-1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-02-23 17:04:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "thesadru",
    "error": "Could not fetch GitHub repository",
    "lcname": "genshinstats-api"
}
        
Elapsed time: 0.20477s