Skip to main content

Wrapper for the MC Championship APIs (Event and Island)

Project description

Python MCC API

🐍 PyPI 👑 Targeting Event API v1.6.0 🏝️ Targeting Island API v25.09.23

A helper library for the MC Championship APIs (Event, inspired by derNiklaas's node-mcc-api project, and Island).

Installation

Ensure that pip is updated using:

python -m pip install --upgrade pip

Then install or update mcc_api using:

pip install --upgrade mcc-api

Usage

Event

The event library provides methods to call each of the endpoints described in the MC Championship Event API's documentation.

from datetime import datetime, timezone
from mcc_api.event import get_event, get_rundown

# Print information about the current event cycle

event = get_event()
event_name = event.data.event
event_start = event.data.date.strftime("%I%p UTC on %A %d %B %Y")

if event.data.date <= datetime.now(tz=timezone.utc):
    print(f"The latest event (MCC {event_name}) started at {event_start}.")
else:
    print(f"The upcoming event (MCC {event_name}) starts at {event_start}.")


# Print the names of the players that played in Dodgebolt in the latest event

rundown = get_rundown()

dodgebolt_teams = rundown.data.dodgeboltData.keys()
players = sorted([player for team in dodgebolt_teams for player in rundown.data.creators[team]], key=str.casefold)

print(f"The players that played in Dodgebolt in the latest event were:\n- {'\n- '.join(players)}")

Island

The island library provides an implementation of the GraphQL schema described in the MCC Island API's documentation. Queries are written in GraphQL, and validated locally before being sent to the API.

Accessing the MCC Island API requires an API key, which can be minted using Noxcrew Gateway. Then, you can use mcc_api.island.set_api_key("<YOUR_API_KEY>") to provide authentication for all future requests. It is recommended that you store your API key in an environment variable, and don't check it in to your source controlled repository.

from gql import gql
from mcc_api.island import client, set_api_key

set_api_key("<YOUR_API_KEY>")

# Print some information about a given player
query = gql("""
    query player($username: String!) {
        playerByUsername(username: $username) {
            username
            status {
                online
            }
            collections {
                currency {
                    coins
                }
            }
            social {
                friends {
                    uuid
                }
            }
        }
    }
""")
data = client.execute(query, variable_values={"username": "Jammy4312"})

player = data["playerByUsername"]
username = player["username"]
username_s = f"{username}'{'' if player['username'][-1].lower() == 's' else 's'}"

print(f"Username: {username}")
if "status" in player:
    print(f"Status:   {'Online' if player['status']['online'] else 'Offline'}")
else:
    print(f"Status:   Unknown ({username_s} status is private)")

if "collections" in player:
    print(f"Coins:    {player['collections']['currency']['coins']:,}")
else:
    print(f"Coins:    Unknown ({username_s} collections are private)")

if "social" in player:
    print(f"Friends:  {len(player['social']['friends']):,}")
else:
    print(f"Friends:  Unknown ({username_s} social data are private)")

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

mcc_api-1.4.1.tar.gz (33.7 kB view details)

Uploaded Source

Built Distribution

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

mcc_api-1.4.1-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file mcc_api-1.4.1.tar.gz.

File metadata

  • Download URL: mcc_api-1.4.1.tar.gz
  • Upload date:
  • Size: 33.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcc_api-1.4.1.tar.gz
Algorithm Hash digest
SHA256 d53fede28369e4aedb31b01e368f2c9395e4b9cc5e247f3efbd096ff536f4024
MD5 f5dcd6578865a15a15c981d2802c6459
BLAKE2b-256 e9afe49a0dc8e42c4b400de2d58a124d4f82fe1dcfb8a02c0e3c941e8e68c849

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcc_api-1.4.1.tar.gz:

Publisher: pypi_publish.yml on JamesMCo/python_mcc_api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcc_api-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: mcc_api-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mcc_api-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 358ea529c7719aa0320351d1386138a2166950ae7c5e167e442b2fcf484b114b
MD5 1e69dac08e85f528215ac2e5b30902c9
BLAKE2b-256 156a13913da402e86bd8e31f3671d24d94b06a13bdb1fae6cb31e8cfc7d0e74b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcc_api-1.4.1-py3-none-any.whl:

Publisher: pypi_publish.yml on JamesMCo/python_mcc_api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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