Arknights python wrapper.
Project description
ArkPRTS
Arknights python wrapper.
This project aims to purely allow for data collection, no account automation is planned.
Source Code: https://github.com/thesadru/arkprts
Usage
import arkprts
async def main() -> None:
client = arkprts.Client()
await client.login_with_email("user@gmail.com")
# or client.login_with_token("123456", "abcdefg")
# get logged-in user data
data = await client.get_data()
print("Level: ", data.status.level)
# get data of other users
users = await client.search_user("UserName")
print("Level: ", users[0].level)
Returned data is in the form of pydantic models, however you can also request raw json with client.get_raw_data()
to access even untyped data.
For convenience, static game data is automatically downloaded and updated on login. You can access the static data directly or through the models. This is useful for getting names and descriptions of objects.
users = await client.search_user("UserName")
operator = users[0].assist_char_list[0] # type: arkprts.models.Character
print(f"Assist operator {operator.static.name} is level {operator.level}")
To disable downloading static data use arkprts.Client(pure=True)
. To choose the data download location set client.gamedata = akprts.GameData("/path/to/data")
.
If you do not trust logging in with your account but still wish to request public game data you may log in as a guest. Remember to save the generated credentials to not spam Arknights servers.
client = arkprts.Client()
uid, token = await client.login_as_guest()
print(f"Please save uid {uid} and token {token}")
users = await client.search_user("Doctor")
# and later if you wish to use the same guest account again
client = arkprts.Client()
await client.login_with_token(uid, token)
users = await client.search_user("Doctor")
Frequent usage cases
Get all of my operators.
data = await client.get_data()
for char in data.troop.chars.values():
print(char.char_id)
Get my inventory.
data = await client.get_data()
# normal inventory items
for item_id, count in user.inventory.items():
if count > 0:
print(item_id, count)
# basic items like originium or green certificates
for item_id, count in user.status.basic_item_inventory.items():
if count > 0:
print(item_id, count)
# consumable expirable items
for item_id, subitems in user.consumable.items():
for item in subitems.values():
if count > 0:
print(item_id, item.ts, item.count)
Contributing
Any kind of contribution is welcome. Please read CONTRIBUTING.md for more information.
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 arkprts-0.1.6.tar.gz
.
File metadata
- Download URL: arkprts-0.1.6.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4953745f4a60013e46bf8fcc501af6edca3f6b8f39657cdeb1bb436611132699 |
|
MD5 | c52514670ea29489d2b8fe1390ce856f |
|
BLAKE2b-256 | a99a7d519c39af6bc944e0a50f067911e497628345f44d2f9286c2e4a8ce609e |
File details
Details for the file arkprts-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: arkprts-0.1.6-py3-none-any.whl
- Upload date:
- Size: 29.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9a5308d69ee90067f28bcc57b31b4e81462fcb6b2d2112e496b3e4bf7ba6e1a |
|
MD5 | f7cef8eb69d9b7cdc211457a6412852a |
|
BLAKE2b-256 | 2ec082d23dcd96ae41600ece1105f1f03bd21c2d47a5e80252da4c05192959f0 |