Skip to main content

AMP API Python


An asynchronous Python wrapper for the CubeCoders AMP (Application Management Panel) API, enabling developers to programmatically manage game server Instances with a clean, Pythonic interface.

Discord Server

Version

Table of Contents


Key Features


  • Pythonic API wrapper using async and await via aiohttp.
  • Data is automatically deserialized into typed dataclasses for easier management and interaction.
    • Optional parameter per function or global to disable formatting of data.
  • Inheritance-based Instance model (Controller, Instance, MinecraftInstance, etc.) groups endpoints by Instance type, preventing invalid calls at the class level.
  • TOTP/2FA authentication support for secure programmatic login via pyotp.
  • Fully typed and verified with Pyright in strict mode, compatible with Python 3.12+.

Docs

Installing


Python 3.12 or higher is required

To install run the below command via your preferred terminal or IDE.

5.0.0 breaks backwards compatibility with 4.x. See Upgrading from 4.x for what changed, or pin cc-ampapi<5 until you're ready~

cc-ampapi 5.x is for an AMP 2 panel. For an AMP 3 panel, install the 6.x beta with pip install --pre "cc-ampapi>=6".

PyPi


-> Visit the package on Pypi

# Linux/macOS/Windows
pip install cc-ampapi

Basic Usage


In your IDE Python file. -> import ampapi.

  1. First you need to fill out the APIParams class with the required fields (url, user and password).
    • A user that signs in through an OIDC provider has no password, so set auth_mode=AuthMode.oidc instead. See the Bridge docs.
  2. Pass the APIParams class into the Bridge class parameter api_params.
    • You only need to make ONE bridge class; the rest of the API classes will get the same object and handle logging in for you.
    • To use your own aiohttp.ClientSession, pass it as Bridge(api_params=..., session=...). You close it yourself.
  3. You can then use the Parent class Controller() or the smaller class Instance() or any of the API classes as a stand alone.
  4. When you are done, close the session with await controller.clean_up(), or use async with Controller() as controller:.

Quick Example -

from typing import Union

from ampapi import (
    AnalyticsFilter,
    AnalyticsSummary,
    APIParams,
    Bridge,
    Controller,
    Instance,
    InstanceState,
    MinecraftInstance,
    Players,
    Status,
)

# You can pull these values from an `.ini` or a `.env` file,
# then populate the dataclass APIParams from `modules -> APIParams`
_params = APIParams(url="http://192.168.13.130:8080",
                    user="amp_username",
                    password="amp_password")



async def Sample_API() -> None:
    """
    Example API Function to call Endpoints.
    """
    _bridge = Bridge(api_params=_params)
    ADS: Controller = Controller()
    # By default all API calls will be formatted into Dataclasses if possible.
    # You can toggle format_data off with ANY of the API classes that inherit Base().
    ADS.format_data = False

    # This would populate the ADS class property .instances
    await ADS.get_instances(format_data=True)
    # We convert the ADS.instances attribute to a list for easier iteration.
    # The data is a set to prevent duplicates.
    ADSinstances = list(ADS.instances)
    arkinstance: Union[Instance, None] = None
    mcinstance: Union[Instance, MinecraftInstance, None] = None
    # We can break out all our instances into their own attributes.
    for instance in ADSinstances:
        # Pre populated from the dataclass and has the API endpoints too!
        # Every converted Instance is already an `Instance`, so there is nothing to check
        if instance.friendly_name == "ArkInstance":
            arkinstance = instance
        elif instance.friendly_name == "Minecraft_PVP":
            mcinstance = instance

    if arkinstance is None or mcinstance is None or not isinstance(mcinstance, MinecraftInstance):
        return
    # This turns back on data formatting Globally.
    arkinstance.format_data = True

    # You can take a backup really easily.
    await arkinstance.take_backup(name="ARK1_backup", description="This is an ARK backup", sticky=True)

    # Then you can call instance type specific API endpoints.
    # AMP 2.6.5.0 removed the whitelist endpoints, so we send the server's own console command instead
    await mcinstance.send_console_message(msg="whitelist add k8_thekat")

    # You can also check attributes and other fields of the instance for easy logic.
    if mcinstance.instance_name == "Test_Server":
        # do code here
        ...

    # The State of the Instance.
    # Can be checked via `Instance.running`.
    # This is cached, call `ADS.get_instances()` again to refresh it.
    if mcinstance.running is True:
        print(f"{mcinstance.friendly_name} is Running Nyao~")

    elif mcinstance.running is False:
        print(f"{mcinstance.friendly_name} is not currently Running.")
        await mcinstance.start_instance()

    # You can also restart and stop the Instance too.
    await mcinstance.restart_instance()
    await mcinstance.stop_instance()

    # The State of the Application. eg. ready, stopped, restarting, etc. See `_enums.py -> InstanceState`
    # This is NOT updated constantly. See about using `get_status()` to get it current.
    if mcinstance.app_state == InstanceState.stopped:
        await mcinstance.start_application()

    # You can also stop and update the application via
    await mcinstance.stop_application()
    await mcinstance.update_application()

    # To get the current Instance State call the function below, it returns a `Status` dataclass.
    # A call gives the raw dict when `format_data` is off, so we ask for the dataclass and check we got it
    status = await mcinstance.get_status(format_data=True)
    if isinstance(status, Status):
        print(status.state)
        # You can also check Metrics of an Instance easily.
        print(status.metrics)

    # Want to kick a random person? Here ya go~
    players = await mcinstance.get_user_list(format_data=True)
    if isinstance(players, Players) and len(players.sorted) > 0:
        await mcinstance.mc_kick_user_by_id(user_id=players.sorted[0].uuid)

    # When you are done, close the session the Bridge made for us.
    await ADS.clean_up()



async def Sample_Analytics_API():
    """
    Example Method to use Instance Analytics.
    """
    ADS: Controller = Controller()
    await ADS.get_instances()
    # The instances are a set, so we pick the first Minecraft one out of it; this is just an example.
    # You can check an Instances Type via the `.module` attribute of any Instance class.
    mcinstance: Union[Instance, MinecraftInstance, None] = None
    for instance in ADS.instances:
        if isinstance(instance, MinecraftInstance):
            mcinstance = instance
            break
    if mcinstance is None:
        return
    # Example analytics call without a filter.
    Analytics = await mcinstance.get_analytics_summary(format_data=True)
    if isinstance(Analytics, AnalyticsSummary):
        # Then with that class you can access lots of Information, such as Top Players, Stats and SessionTime.
        print(Analytics.top_players) # This is a list of this Instances Top Players.
        print(Analytics.stats) # This is a list of different fields such as Unique Users, New Users, etc..
    # _____________________________________________
    # Now you can also filter the results to look at a specific User or Country. Simply define the `AnalyticsFilter` class and pass it into the method call.
    country_filter: AnalyticsFilter = AnalyticsFilter(country="US") # The country parameter supports `ISO 3166-1 Alpha-2 format` only.
    # These results will be filtered to only users within the US.
    filtered_analytics = await mcinstance.get_analytics_summary(filters=country_filter, format_data=True)
    print(filtered_analytics)

    user_filter: AnalyticsFilter = AnalyticsFilter(username="k8_thekat") # The IGN/Username of the user connected to the Server.
    # These results will be filtered to only users with that match the parameter username. (eg. k8_thekat).
    filtered_analytics2 = await mcinstance.get_analytics_summary(filters=user_filter, format_data=True)
    print(filtered_analytics2)

    # When you are done, close the session the Bridge made for us.
    await ADS.clean_up()

Controlling data formatting -

  • All JSON data returned from the API endpoints is formatted into a Dataclass/Enum/etc if possible.
  • Data formatting can be controlled globally or locally by changing the format_data parameter of the method to False.
    • When turning off the data formatting, typically you will get a dictionary back.

Example -

# You must have your Bridge object made and the Instance class created to access `format_data`.
# By default all API calls will be formatted into Dataclasses if possible.
# You can toggle format_data off with ANY of the API classes that inherit Base().
ADS.format_data = False

# You can turn data formatting back on globally through any Instance object.
arkinstance.format_data = True

# You can turn off or on data formatting per function also.
await arkinstance.get_updates(format_data=False)
await arkinstance.get_role_data(format_data=True)

Contributing to the Project

See CONTRIBUTING.md for setup, the checks to run, the commit message format, and the dev tools. Those tools cover calling endpoints that have no wrapper yet, capturing responses, checking captures for key drift with KeyDriftCheck, and regenerating the spec sheets when AMP updates~

Metadata

Release files for cc-ampapi 5.0.1

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

Source distribution (sdist)

Source distribution for cc-ampapi 5.0.1
File Size Uploaded Provenance Actions
cc_ampapi-5.0.1.tar.gz 202.7 kB With provenance Details for cc_ampapi-5.0.1.tar.gz

Release files / cc_ampapi-5.0.1.tar.gz

Download URL cc_ampapi-5.0.1.tar.gz
Size 202.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e0fcda15ec2c094d4be5a25372c7237fea50cfefff5cf754d524149a628ae5ce
BLAKE2b-256 checksum
How to use checksums
8a3f48bf705d863a555bb223a9a4c21099cb471cfbbf8fcec4d67d248cbc73e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for cc-ampapi 5.0.1

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.

Full provenance

1 file in this release has been uploaded with provenance metadata.

Attestation for cc_ampapi-5.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

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