This release is a pre-release and may not be stable for production use.
AMP API Python
CubeCoders AMP 3 API wrapper in Python.
This is the AMP 3 beta,
6.0.0b6. It is built against AMP 3's preview builds, tested on AMP 3.0.0, 3.0.1 and 3.0.2, and only talks to AMP 3. For AMP 2, use the 5.x releases, which keep supporting it. A plainpip install cc-ampapinever picks up this beta.A version named in the docs, eg. "AMP 3.0.0", is AMP's version. The library's own version is
ampapi.__version__.
AMP 3
- AMP 3's API is not published. Every call here was worked out from the web panel, so any of them can change between AMP builds.
- AMP 3 renamed some of AMP's terms, and the library uses AMP 3's terms:
- An Instance is a shard (
Shard). - An ADS or a Target is a spire (
Spire). - A game definition is a template, eg.
minecraft-javaorteeworlds.
- An Instance is a shard (
- Coming from 5.x,
Sessiontakes the place ofBridgeandPaneltakes the place ofController.
Key Features
- Pythonic API wrapper using
asyncandawait, built onaiohttp. Sessionhandles the login: it renews the token before it runs out, logs in again when AMP ends the session, waits out a short AMP outage the way the web panel does, and takes a recovery code when the account needs a second factor. Calls waiting on a login that fails all raise its error, rather than each trying again.Panelgroups every API area (accounts, analytics, audit, credentials, enrolments, networking, platform, shards, spires, tasks and templates) in one object.- Taking an invite needs no account yet: make a
Sessionwith any username, eg."", and the password you want, then callsession.accept_invite(...). It logs in as the new account. ShardandSpireobjects carry the calls that act on them, eg.await shard.start().- Typed replies:
TypedDicts for most calls, and small objects for live data such asShardStatus,ConsoleLineandRunningTask. The package shipspy.typed. - File downloads and uploads, including AMP's chunked upload for big files.
- Every request and AMP's reply can be saved as redacted JSON files, see Capturing replies.
Docs
- There are no hosted docs for the 6.0 beta yet. The docstrings carry them, so your editor's hover is the place to look.
- The 5.x docs are at https://ampapi-python.readthedocs.io/en/latest/
Installing
Python 3.12 or higher is required
PyPi
-> Visit the package on Pypi
The beta is a pre-release, so pip only picks it up with --pre. This works once the beta is published to PyPI:
# Linux/macOS/Windows
pip install --pre cc-ampapi
Until then, install it from this branch on GitHub:
pip install git+https://github.com/k8thekat/AMPAPI_Python@AMP3-beta
Basic Usage
In your IDE Python file. -> import ampapi.
- Make a
Sessionwith the panel's URL and a login. It logs in on the first call that needs it. - Hand it to a
Panel, which has the API calls. Logging in and taking an invite are on theSessionitself.- Leaving an
async withblock, orawait panel.clean_up(), logs out and closes the session.
- Leaving an
- A call on the
Paneltakes IDs, eg.panel.start_shard(shard_id=...). The same call on aSharddrops the ID, eg.shard.start().
import asyncio
from ampapi import Panel, Session, Shard, ShardState, ShardStatus
async def main() -> None:
# You can pull these values from an `.ini` or a `.env` file.
session = Session(url="http://192.168.1.10:8443", username="amp_username", password="amp_password")
async with Panel(session=session) as panel:
shards: list[Shard] = await panel.get_shards()
for shard in shards:
state: ShardStatus = await shard.get_state()
print(shard.display_name, state.status, state.is_running)
# AMP answers a start before the game is up, so check `get_state()` again to see it running.
if shard.display_name == "Minecraft" and state.status == ShardState.stopped:
await shard.start()
asyncio.run(main())
See samples for scripts you can run against your own panel. Each one reads the panel's URL and login from AMP_URL, AMP_USER and AMP_PASSWORD. shard_control.py and files.py also take the shard's ID from AMP_SHARD.
basic.py: log in, list the spires and shards, and read a shard's state.shard_control.py: start a shard, send a console command, read the console back and stop it.files.py: list, upload, read, download and delete a shard's files.
Capturing replies
A Session can save every request it sends, and AMP's reply, as a JSON file. It's handy for a bug report, or for seeing what AMP really sent when a reply doesn't match its type.
Session(..., capture_dir=Path("captures"))captures the whole run.with session.capture(Path("captures")):captures only the calls made inside the block.- Every call is captured, logins, renewals and error replies included. Each file is named from the method and the path, with each ID as
{id}, then the UTC time to the microsecond, eg.GET_api_shards_{id}_state_2026-11-13_21-52-07.123456.json, so a route's files sort in time order. A file already in the folder is never written over. - Inside a
captureblock, acapture_dirthe session was made with still gets every reply too. - Each file holds the request (method, path, query parameters, headers and body) and the reply (status, the useful headers and body). A download or any other binary reply is kept as its content type and length only.
- Captures are redacted by default: tokens, passwords, keys, recovery codes and the
Authorizationheader become<redacted str len=N>, a game's sign-in code is blanked, and public IP addresses become<public ip>. Private addresses are kept.redact=Falsewrites them as sent, so keep those files to yourself. - A capture that fails to write, eg. to a read-only folder, is logged as a warning and the call carries on.
from pathlib import Path
from ampapi import Panel, Session
# Inside an `async with Panel(session=session) as panel:` block.
with session.capture(Path("captures")):
await panel.get_shards()
Errors
The errors from AMP are all AMPAPIErrors. When AMP answers a call with an error, you get an AMPAPIRequestError carrying whatever AMP sent:
.status: the HTTP status code..code: AMP's dotted error key, eg.shards.error.eulaRequired, when it sends one..message: AMP's message, when it sends one..errors: the validation errors, eg. for a password the policy refuses, when it sends any..data: the whole body: the decoded JSON, or the text of a reply that isn't JSON, eg. a proxy's error page.
from ampapi import AMPAPIRequestError
try:
await shard.start()
except AMPAPIRequestError as error:
if error.code == "shards.error.eulaRequired":
await shard.accept_eula()
else:
print(error.status, error.code, error.message)
A login that can't finish raises its own:
AMPAPILoginErrorfor a wrong username or password.AMPAPIPasskeyRequiredErrorwhen the account needs a second factor. Send one of its recovery codes tosession.second_factor(code=...).AMPAPIPasswordChangeRequiredErrorwhen AMP wants a new password first.session.change_expired_password(new_password=...)sets it and logs in.
Metadata
Release files for cc-ampapi 6.0.0b6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cc_ampapi-6.0.0b6.tar.gz | 198.2 kB | With provenance | Details for cc_ampapi-6.0.0b6.tar.gz |
Release files / cc_ampapi-6.0.0b6.tar.gz
| Download URL | cc_ampapi-6.0.0b6.tar.gz |
|---|---|
| Size | 198.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e5bb01d7ba9d8ba346b57830dd2b440f4cfd8122de350bb883cb349a4853162d
|
|
BLAKE2b-256 checksum How to use checksums |
b012150f1e95710602c6e3b548239f5e047c4d9033f892dae92d81405f1c0d3f
|
| 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 26, 2026.
Transparency logSecurity for cc-ampapi 6.0.0b6
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-6.0.0b6.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 26, 2026.
Transparency logA 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.