### Set up virtual environment and install dev dependencies Source: https://github.com/ashleney/arkprts/blob/master/CONTRIBUTING.md Creates a virtual environment, activates it, and installs development dependencies required for contributing to arkprts. ```sh python -m venv .venv source .venv/bin/activate pip install ./dev-requirements[all] ``` -------------------------------- ### Install arkprts with all optional dependencies Source: https://github.com/ashleney/arkprts/blob/master/README.md Installs arkprts along with all optional requirements. ```sh pip install -U arkprts[all] ``` -------------------------------- ### Get auth tokens via web endpoints Source: https://github.com/ashleney/arkprts/blob/master/README.md Example web endpoints for sending an email code and exchanging it for Yostar auth tokens. ```py @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} ``` -------------------------------- ### Install arkprts with pip Source: https://github.com/ashleney/arkprts/blob/master/README.md Installs the latest version of the arkprts package from PyPI. ```sh pip install -U arkprts ``` -------------------------------- ### Get inventory items Source: https://github.com/ashleney/arkprts/blob/master/README.md Shows how to iterate over different inventory types: normal items, basic items, and consumable expirable items. ```py 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) ``` -------------------------------- ### Get all owned operators Source: https://github.com/ashleney/arkprts/blob/master/README.md Iterates over all owned operators and prints their character IDs. ```py data = await client.get_data() for char in data.troop.chars.values(): print(char.char_id) ``` -------------------------------- ### Access static data via models Source: https://github.com/ashleney/arkprts/blob/master/README.md Demonstrates accessing static game data through models, e.g., getting an operator's name and level. ```py 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}") ``` -------------------------------- ### Basic client usage and login Source: https://github.com/ashleney/arkprts/blob/master/README.md Shows basic usage: creating a client, searching players, logging in with email code or token, and fetching user data. ```py 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) ``` -------------------------------- ### Create authenticated client from guest client Source: https://github.com/ashleney/arkprts/blob/master/README.md Creates a new authenticated client reusing the network and assets from an existing guest client to avoid overhead. ```py 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) ``` -------------------------------- ### VSCode settings.json for arkprts development Source: https://github.com/ashleney/arkprts/blob/master/CONTRIBUTING.md VSCode settings to enable formatting on save, set the Python interpreter to the virtual environment, use black as the formatter, and run fix all actions on save for Python files. ```json { "editor.formatOnSave": true, "python.defaultInterpreterPath": ".venv/bin/python", "python.formatting.provider": "black", "[python]": { "editor.codeActionsOnSave": { "source.fixAll": true } } } ```