An API wrapper for Genshin Impact.
Project description
genshin.py
Modern API wrapper for Genshin Impact built on asyncio and pydantic.
Documentation: https://thesadru.github.io/genshin.py
Source Code: https://github.com/thesadru/genshin.py
The primary focus of genshin.py is convenience. The entire project is fully type-hinted and abstracts a large amount of the api to be easier to use.
Key features:
- All data is in the form of Pydantic Models which means full autocompletion and linter support.
- Requests are significantly faster thanks to proper usage of asyncio.
- Chinese and Engrish names returned by the API are renamed to simpler English fields.
- Supports the majority of the popular endpoints.
- Cleanly integrates with frameworks like FastAPI out of the box.
Note: This library is a successor to genshinstats - an unofficial wrapper for the Genshin Impact api.
Requirements
- Python 3.8+
- aiohttp
- Pydantic
pip install genshin
Example
A very simple example of how genshin.py would be used:
import asyncio
import genshin
async def main():
cookies = {"ltuid": 119480035, "ltoken": "cnF7TiZqHAAvYqgCBoSPx5EjwezOh1ZHoqSHf7dT"}
client = genshin.GenshinClient(cookies)
data = await client.get_user(710785423)
print(f"User has a total of {len(data.characters)} characters")
await client.close()
asyncio.run(main())
Contributing
Any kind of contribution is welcome.
Before making a pull request remember to test your changes using pytest.
Remember to set your LTUID
and LTOKEN
environment variables.
pip install genshin[test]
python -m pytest
Please also edit the documentation accordingly. You may see how the final documentation would look like by starting an mkdocs
server.
pip install genshin[doc]
mkdocs serve
I am currently looking for any chinese mainland players who could share their account_id
and cookie_token
cookies to allow for testing of chinese endpoints.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file genshin-0.1.0.tar.gz
.
File metadata
- Download URL: genshin-0.1.0.tar.gz
- Upload date:
- Size: 36.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92a68504b27c2389bb85775fed1577cbc94b5437c0f8069ead39f7dbc36a700f |
|
MD5 | da0faa206806b121950c1ea2e48a725c |
|
BLAKE2b-256 | 3bed08ae64ac037c19e078ea155c537f4bb2716ce43e3849667fef87e33d9046 |
File details
Details for the file genshin-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: genshin-0.1.0-py3-none-any.whl
- Upload date:
- Size: 43.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2474f09ef83575f6c8feef8f25fb6ebc3e36a7618f54ceb98600fc749fc3e06f |
|
MD5 | 11adb034e76bc5da688ac4da42be7e57 |
|
BLAKE2b-256 | 47d8ffdd84fffa5b2f9df8396e9cde32cdc4d5b514fb404d2c840e029abdc043 |