Skip to main content

Python 3 interface library for the Mhanndalorianbot authenticated endpoints API

Project description

Mhanndalorian_Bot

Mhanndalorian_Bot is a Python library for interacting with the SWGOH Mhanndalorian Bot authenticated API and Player Registry endpoints.

See https://mhanndalorianbot.work/api.html for more details

Installation

Use the Python package manager pip to install Mhanndalorian_Bot.

   pip install mhanndalorian-bot

Usage

Before accessing the Mhanndalorian Bot APIs you must first register for an apikey. Instructions for generating an apikey can be found here.

Basic Usage

Authenticated API Endpoint Interaction

from mhanndalorian_bot import API, EndPoint

mbot = API(api_key=<YOUR APIKEY>, allycode=<YOUR ALLYCODE>)

resp = mbot.fetch_data(endpoint=EndPoint.INVENTORY)

Player Registry Interaction

from mhanndalorian_bot import Registry

mbot = Registry(api_key=<YOUR APIKEY>, allycode=<YOUR ALLYCODE>, discord_id=<YOUR DISCORD USER ID>)

resp = mbot.fetch_player(allycode=<PLAYER ALLYCODE>)

Advanced Usage

mhanndalorian_bot includes async methods in both the API and Registry modules. These are provided to facilitate usage within Python scripts that may primarily make use of the asyncio (or equivalent) module, such as Discord bots. Since the Mhanndalorian web services/APIs deal with SWGOH player registration and data access, it is likely that the primary consumers of those services will be bots.

Authenticated API Endpoint Interaction

import asyncio
from mhanndalorian_bot import API, EndPoint

async def main():
    mbot = API(api_key="super_secret_test_key", allycode="123456789")
    
    fetch_data_resp = await mbot.fetch_data_async(EndPoint.INVENTORY)

    if isinstance(fetch_data_resp, dict):
        if 'msg' in fetch_data_resp:
            # An unexpected error occurred
            print(f"An unexpected error occurred: {fetch_data_resp}")
        elif 'inventory' in fetch_data_resp:
            material: list = fetch_data_resp['inventory']['material']
            currency: list = fetch_data_resp['inventory']['currencyItem']
            equipment: list = fetch_data_resp['inventory']['equipment']
            unequipped_mods: list = fetch_data_resp['inventory']['unequippedMod']
        else:
            raise RuntimeError("Not sure what happened.")

if __name__ == '__main__':
    asyncio.run(main())

Player Registry Interaction

import asyncio
from mhanndalorian_bot import Registry

async def main():
    reg = Registry(api_key=<YOUR API KEY>, allycode=<YOUR ALLYCODE>, discord_id=<YOUR DISCORD USER ID>)

    # Returns 'None' if player does not exist in the registry
    fetch_resp = await reg.fetch_player_async(allycode)

    if isinstance(fetch_resp, dict):
        if 'msg' in fetch_resp:
            # An unexpected error occurred
            print(f"An unexpected error occurred: {fetch_resp}")
        else:
            player_allycode = fetch_resp['allyCode']
            player_discord_id = fetch_resp['discordId']

if __name__ == '__main__':
    asyncio.run(main())

More information can be found on GitHub

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

mhanndalorian_bot-0.10.0.tar.gz (68.1 kB view details)

Uploaded Source

Built Distribution

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

mhanndalorian_bot-0.10.0-py3-none-any.whl (105.8 kB view details)

Uploaded Python 3

File details

Details for the file mhanndalorian_bot-0.10.0.tar.gz.

File metadata

  • Download URL: mhanndalorian_bot-0.10.0.tar.gz
  • Upload date:
  • Size: 68.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for mhanndalorian_bot-0.10.0.tar.gz
Algorithm Hash digest
SHA256 60e6a3a6b8362c09b913fc4540eaa75e7dab64a7ddd11a349caf1ef28565cbfc
MD5 6682f0d11573b2da5baf8d55a7bc6a05
BLAKE2b-256 127959295d23c2266eb0da91650750422d5822b5ade6ba6a709fa1045c05901c

See more details on using hashes here.

File details

Details for the file mhanndalorian_bot-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mhanndalorian_bot-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cbb82f078e516e8da7e9a68c4c2252eb277b3e8cb1a4540ae8977dcc01570f3a
MD5 a99638291fe1ceb53f7b860eb21a6313
BLAKE2b-256 4a2a7cbe0b082b1718e40c09143b0879a4d54c09bc1de0095bf2944d4f0dfc53

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