Query Apple Business Manager using Python
Project description
The purpose of this repo is to create a python library to easily get information using the Apple Business Manager API using Python.
A CLI command is also included, pyacm-cli.
https://developer.apple.com/documentation/applebusinessmanagerapi
Setup
If you want to setup the authentication using envvars, do the following:
You will need to setup 2 environmental variables that are provided when creating the private key in ABM:
AXM_CLIENT_ID and AXM_KEY_ID
Place the private key in your home directory inside the .config/pyaxm folder
and rename it key.pem
This location will be used to store a cached access_token that can be reused until it expires. While testing I have experienced that requesting too many access tokens will result in a response with status code 400 when trying to get a new token.
Otherwise you will have to pass the client id, key id and private key as arguments to the client like so:
from pyaxm.client import Client
axm_client = Client(
axm_client_id="CLIENT_ID",
axm_key_id="KEY_ID",
key_path="PRIVATE_KEY",
token_path="TOKEN_PATH"
)
The token path is the location where the access token will be stored.
Installation:
pip install pyaxm
CLI:
A command-line interface (CLI) tool called pyaxm-cli is included for easy access to the API.
Overview
The CLI provides a convenient way to interact with the Apple Business Manager API directly from your terminal. It includes commands for managing devices, MDM servers, and retrieving device information.
Detailed Documentation
For comprehensive documentation of all available commands, options, and usage examples, please refer to the CLI documentation.
Updating Documentation
The CLI documentation is automatically generated from the code. To update it after making changes to the CLI implementation, run:
typer pyaxm.cli utils docs --name pyaxm-cli --output docs/cli.md
A GitHub workflow automatically checks that the documentation stays in sync.
Client:
Example usage:
from pyaxm.client import Client
axm_client = Client()
devices = axm_client.list_devices()
print(devices)
device = axm_client.get_device(device_id='SERIAL_NUMBER')
print(device)
mdm_servers = axm_client.list_mdm_servers()
print(mdm_servers)
# The MDM server ID can be extracted from listing all mdm servers
mdm_server = axm_client.list_devices_in_mdm_server(server_id="MDM_SERVER_ID")
print(mdm_server)
device_assigned_server = axm_client.list_devices_in_mdm_server(device_id='SERIAL_NUMBER')
print(device_assigned_server)
assignment_result = axm_client.assign_unassign_device_to_mdm_server(
device_ids=['SERIAL_NUMBER', "ANOTHER_SERIAL_NUMBER"],
server_id="MDM_SERVER_ID",
action="ASSIGN_DEVICES"|"UNASSIGN_DEVICES"
)
print(assignment_result)
apple_care_coverage = axm_client.get_apple_care_coverage(device_id='SERIAL_NUMBER')
print(apple_care_coverage)
Issues:
- need to add tests
This is still a work in progress
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyaxm-2026.5.18.tar.gz.
File metadata
- Download URL: pyaxm-2026.5.18.tar.gz
- Upload date:
- Size: 25.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df8a664d5528021a260411c305eed3ecb3699b631fe025c4ff249a075488aed6
|
|
| MD5 |
49445174877a2219616629d00aae4ff6
|
|
| BLAKE2b-256 |
b618e149507eec102a5b1b8796d53b61b80356e3866bf7a78513e0cd71ba81e9
|
Provenance
The following attestation bundles were made for pyaxm-2026.5.18.tar.gz:
Publisher:
release.yml on kaincenteno/pyaxm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyaxm-2026.5.18.tar.gz -
Subject digest:
df8a664d5528021a260411c305eed3ecb3699b631fe025c4ff249a075488aed6 - Sigstore transparency entry: 1568747076
- Sigstore integration time:
-
Permalink:
kaincenteno/pyaxm@077bb1a738534c2e50173c2a1154ace47da241b6 -
Branch / Tag:
refs/tags/2026.5.18 - Owner: https://github.com/kaincenteno
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@077bb1a738534c2e50173c2a1154ace47da241b6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyaxm-2026.5.18-py3-none-any.whl.
File metadata
- Download URL: pyaxm-2026.5.18-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f03cf8313ca3a7bef3ec0d432b7a053729d21b134f9e656589774961f28042eb
|
|
| MD5 |
9b0374f8ceb4dcd784c15f9cb224eb11
|
|
| BLAKE2b-256 |
f398101ec2f601f5e8c1a8e054c2a86b2716bf3376a85625b4f1586bd9587619
|
Provenance
The following attestation bundles were made for pyaxm-2026.5.18-py3-none-any.whl:
Publisher:
release.yml on kaincenteno/pyaxm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyaxm-2026.5.18-py3-none-any.whl -
Subject digest:
f03cf8313ca3a7bef3ec0d432b7a053729d21b134f9e656589774961f28042eb - Sigstore transparency entry: 1568747126
- Sigstore integration time:
-
Permalink:
kaincenteno/pyaxm@077bb1a738534c2e50173c2a1154ace47da241b6 -
Branch / Tag:
refs/tags/2026.5.18 - Owner: https://github.com/kaincenteno
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@077bb1a738534c2e50173c2a1154ace47da241b6 -
Trigger Event:
release
-
Statement type: