Skip to main content

ArkPRTS

Arknights python wrapper.

Interacts directly with the game servers, no delays.


Source Code: https://github.com/thesadru/arkprts


Installation

pip install -U arkprts

There are some optional requirements, you can install them all with all.

pip install -U arkprts[all]

Usage

import arkprts

async def main() -> None:
    client = arkprts.Client(assets=False)

    # search users by nickname
    users = await client.search_players("Doctor", server="en")
    print("User level: ", users[0].level)


    # =======

    # login with email or token
    auth = arkprts.YostarAuth("en")
    await auth.login_with_email_code("doctor@gmail.com")
    # or auth.login_with_token("123456", "abcdefg")
    client = arkprts.Client(auth=auth, assets=False)

    # get logged-in user data
    data = await client.get_data()
    print("Level: ", data.status.level)

Returned data is in the form of pydantic models, however you can also request raw json with client.get_raw_player_info()/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(assets=False). To choose the data download location set arkprts.Client(assets="/path/to/data") (/tmp/%TEMP% is chosen by default).

ArkPRTS supports en, jp, kr, cn and bili servers. However only global/yostar servers (en, jp and kr) can be used without logging in.

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)

Making a new client when a global guest client already exists; without excess overhead.

public_client = arkprts.Client()

# ----
auth = arkprts.YostarAuth("en", network=public_client.network)
await auth.login_with_token("123456", "abcdefg")
private_client = arkprts.Client(auth=auth, assets=public_client.assets)

Programmatically getting auth tokens from a user on your website.

@route("/code")
def code(request):
    auth = arkprts.YostarAuth(request.query["server"], network=...)
    await auth.send_email_code(request.query["email"])

    return "Code sent!"


@route("/login")
def login(request):
    auth = arkprts.YostarAuth(request.query["server"], network=...)
    yostar_uid, yostar_token = await auth.get_token_from_email_code(request.query["email"], request.query["code"])

    return {"yostar_uid": yostar_uid, "yostar_token": yostar_token}

Contributing

Any kind of contribution is welcome. Please read CONTRIBUTING.md for more information.

Thanks

Many thanks to all of these people and projects

Implementing your own wrapper

See logs.txt for example requests and responses when trying to search a user on a YoStar server.

Metadata

Release files for arkprts 0.3.22

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arkprts 0.3.22
File Size Uploaded
arkprts-0.3.22.tar.gz 54.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for arkprts 0.3.22
File Interpreter ABI Platform
arkprts-0.3.22-py3-none-any.whl Python 3 none any Details

Total release size: 111.9 kB

Release files / arkprts-0.3.22.tar.gz

Download URL arkprts-0.3.22.tar.gz
Size 54.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0586760562399a51aa3f2c677c24e60b9fcae4bcc06e1919fc657073bf8e931c
BLAKE2b-256 checksum
How to use checksums
4fc11ab30a14ab5beda669d7058aa0783f5bf9f74091167fd9d8b8ed08cb982a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / arkprts-0.3.22-py3-none-any.whl

Download URL arkprts-0.3.22-py3-none-any.whl
Size 57.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb21b974b184d0b2d2ea47d68ca2e8102fe4c4682d663b0dcce228bcdf04419b
BLAKE2b-256 checksum
How to use checksums
230c4b71827496035c6ad058632c20cf09a9338c8f47d3594b1501db19f7190c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page