MCC Island API

mcc_api.island.client = <gql.client.Client object>

An instance of gql.Client configured to make requests to the MCC Island API.

Must be provided an API key using set_api_key(), otherwise requests will be rejected with an HTTP 401 status code by the API.

Queries can be executed by passing the result of gql.gql() object to client.execute(). Queries are verified to be valid using according to the schema before being sent to the API, raising a graphql.GraphQLError if not. The returned data will be a Python dictionary whose structure matches that of the query. Data returned as a UUID, a Date, or a DateTime will be resolved as a UUID, a date, or a datetime object respectively. Some data may not be present if the user being queried has kept some of their data private to the API.

Note

All API settings (collections, social, statistics, and status) are opt-in, and so all related data will be private unless a player has explicitly chosen to enable them.

For example, to calculate the win percentage for a player in Parkour Warrior: Survivor, the following code could be used:

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

set_api_key("<YOUR_API_KEY>")

query = gql("""
    query pkwStats($username: String!) {
        playerByUsername(username: $username) {
            username
            statistics {
                total_games: value(statisticKey: "pw_survival_games_played") { value }
                total_wins: value(statisticKey: "pw_survival_final_duel_wins") { value }
            }
        }
    }
""")

data = client.execute(query, variable_values={"username": "Jammy4312"})
player = data["playerByUsername"]

username = player["username"]
if "statistics" in player:
    total_games = player["statistics"]["total_games"]["value"]
    total_wins = player["statistics"]["total_wins"]["value"]
    win_rate = (total_wins / total_games) * 100 if total_games > 0 else 0

    print(f"{username} has won {win_rate}% of their {total_games} Parkour Warrior: Survivor games.")
else:
    print(f"{username}'{'' if username[-1].lower() == 's' else 's'} collections are private.")
mcc_api.island.set_api_key(api_key: str) None

Set the API key to use as authentication for all future requests to the MCC Island API.

API keys can be minted using Noxcrew Gateway.