Skip to main content

Python MCC API

🐍 PyPI 👑 Targeting Event API v1.6.0 🏝️ Targeting Island API v24.05.06

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)")

Metadata

Release files for mcc-api 1.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcc-api 1.1.7
File Size Uploaded Provenance Actions
mcc_api-1.1.7.tar.gz 29.7 kB Without provenance Details for mcc_api-1.1.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcc-api 1.1.7
File Interpreter ABI Platform Actions
mcc_api-1.1.7-py3-none-any.whl Python 3 none any Details for mcc_api-1.1.7-py3-none-any.whl

Total release size: 47.7 kB

Release files / mcc_api-1.1.7.tar.gz

Download URL mcc_api-1.1.7.tar.gz
Size 29.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1037ec00bbaf34780e7bbe25b560acd58866d8f5b034cd5d88baf46ac26538e9
BLAKE2b-256 checksum
How to use checksums
9153cf7b2c9b30e1ab0012e3b908e1176d00cb7e6e3728392e115dbac0a98d1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release files / mcc_api-1.1.7-py3-none-any.whl

Download URL mcc_api-1.1.7-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b5e61bf6e85eaa7b3fadebe107b8fe9e76a54571cfad024edf1bc1d92b1c037
BLAKE2b-256 checksum
How to use checksums
814c174a085022c63178f74480f12825e94528b4515bbc846f26839a595be901
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Security for mcc-api 1.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page