Skip to main content

Arknights python wrapper.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arkprts-0.3.18.tar.gz (53.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

arkprts-0.3.18-py3-none-any.whl (56.9 kB view details)

Uploaded Python 3

File details

Details for the file arkprts-0.3.18.tar.gz.

File metadata

  • Download URL: arkprts-0.3.18.tar.gz
  • Upload date:
  • Size: 53.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for arkprts-0.3.18.tar.gz
Algorithm Hash digest
SHA256 9a231269c23a799fd815c27a039f0661d9247b7135d9a1f12b2618aeead926c5
MD5 82fcf941f278a8980cc84ad2cf28863d
BLAKE2b-256 6567102d8db873e558b130b8593ac4c7c48f0a62d3228bf44f8a4bfa2341340c

See more details on using hashes here.

File details

Details for the file arkprts-0.3.18-py3-none-any.whl.

File metadata

  • Download URL: arkprts-0.3.18-py3-none-any.whl
  • Upload date:
  • Size: 56.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for arkprts-0.3.18-py3-none-any.whl
Algorithm Hash digest
SHA256 9d1a6181acf7eb1fd5c2f65e9c8fb6dd26c7fb1c4d0e714bdea22ce7ebc37f5d
MD5 7d7b75e46326653466bb2a915aca5a97
BLAKE2b-256 4fcc1728149f780f87afb29f337fc9f3313181fb87c660f92778e904505e7d62

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page