Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyaxm-2025.12.1.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyaxm-2025.12.1-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file pyaxm-2025.12.1.tar.gz.

File metadata

  • Download URL: pyaxm-2025.12.1.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyaxm-2025.12.1.tar.gz
Algorithm Hash digest
SHA256 bc30a5a545ec22352bee7eeef8deaf31c186978bf53a744206029cabdee48cf4
MD5 306865c64365c8da49d261465bda1cbf
BLAKE2b-256 ae9aaf080f2c88784c2a60543c10e77425674570f7ae035b4cca232a2abd5f1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyaxm-2025.12.1.tar.gz:

Publisher: release.yml on kaincenteno/pyaxm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyaxm-2025.12.1-py3-none-any.whl.

File metadata

  • Download URL: pyaxm-2025.12.1-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyaxm-2025.12.1-py3-none-any.whl
Algorithm Hash digest
SHA256 baea018eb2a1116a4b3cc509faa04abacc438dfc65f7d2a9f75b2be1f876114b
MD5 a993fc1048ff5f9d0ade0876fafccd7b
BLAKE2b-256 f21ce01d6af9df6fd5e4fa3c6d155413cfd64ef413e73849a089f1a21c109e30

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyaxm-2025.12.1-py3-none-any.whl:

Publisher: release.yml on kaincenteno/pyaxm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page