Package: arkprts
ArkPRTSArknights python wrapper.Interacts directly with the game servers, no delays.支持中文和B站账户!Source Code:https://github.com/thesadru/arkprtsInstallationpipinstall-UarkprtsThere are some optional requirements, you can install them all withall.pipinstall-Uarkprts[all]Usageimportarkprtsasyncdefmain()->None:client=arkprts.Client(assets=False)# search users by nicknameusers=awaitclient.search_players("Doctor",server="en")print("User level: ",users[0].level)# =======# login with email or tokenauth=arkprts.YostarAuth("en")awaitauth.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 datadata=awaitclient.get_data()print("Level: ",data.status.level)Returned data is in the form of pydantic models, however you can also request raw json withclient.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=awaitclient.search_user("UserName")operator=users[0].assist_char_list[0]# type: arkprts.models.Characterprint(f"Assist operator{operator.static.name}is level{operator.level}")To disable downloading static data usearkprts.Client(assets=False). To choose the data download location setarkprts.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 casesGet all of my operators.data=awaitclient.get_data()forcharindata.troop.chars.values():print(char.char_id)Get my inventory.data=awaitclient.get_data()# normal inventory itemsforitem_id,countinuser.inventory.items():ifcount>0:print(item_id,count)# basic items like originium or green certificatesforitem_id,countinuser.status.basic_item_inventory.items():ifcount>0:print(item_id,count)# consumable expirable itemsforitem_id,subitemsinuser.consumable.items():foriteminsubitems.values():ifcount>0:print(item_id,item.ts,item.count)Logging in with email and password to the cn server.auth=arkprts.HypergryphAuth()awaitauth.login("doctor@qq.com","wordpass12")client=arkprts.Client(auth=auth)awaitclient.get_data()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)awaitauth.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")defcode(request):auth=arkprts.YostarAuth(request.query["server"],network=...)awaitauth.get_token_from_email_code(request.query["email"])return"Code sent!"@route("/login")deflogin(request):auth=arkprts.YostarAuth(request.query["server"],network=...)channel_uid,yostar_token=awaitauth.get_token_from_email_code(request.query["email"],request.query["code"])return{"channel_uid":channel_uid,"yostar_token":yostar_token}ContributingAny kind of contribution is welcome.
Please readCONTRIBUTING.mdfor more information.