Skip to main content

Official Python SDK for the MachineID.io API

Project description

MachineID.io Python SDK

Official Python client for the MachineID.io API.

This SDK provides a thin wrapper around the core device and usage endpoints:

  • POST /api/v1/devices/register
  • GET /api/v1/devices/validate
  • GET /api/v1/devices/list
  • POST /api/v1/devices/revoke
  • POST /api/v1/devices/unrevoke
  • POST /api/v1/devices/remove
  • GET /api/v1/usage

All calls use the x-org-key header and return the raw JSON from the API.


Installation

For now, install by cloning the repo and installing dependencies manually:

git clone https://github.com/machineid-io/python-sdk.git
cd python-sdk
pip install requests

Quick Start

from machineid import MachineID

client = MachineID("org_1234567890abcdef")
device_id = "agent-01"

# Check usage / plan limits
usage = client.usage()
print("Plan:", usage["planTier"], "Limit:", usage["limit"])

# Register a device (idempotent)
reg = client.register(device_id)
print("Register status:", reg["status"])

# Validate before performing work
val = client.validate(device_id)
if val.get("allowed"):
    print("Device allowed:", val.get("reason"))
else:
    print("Device blocked:", val.get("reason"))

API Methods

All methods require an org_key:

from machineid import MachineID
client = MachineID("org_1234567890abcdef")

usage()

usage = client.usage()
print(usage)

Returns plan tier, plan state, access clock, device counts, and limit status.


register(device_id: str)

reg = client.register("agent-01")
print(reg)

Returns one of:

  • ok
  • exists
  • restored
  • limit_reached

validate(device_id: str)

val = client.validate("agent-01")
print(val)

Use this before agents perform major tasks.


list_devices()

devices = client.list_devices()
print(devices)

Returns all active + revoked devices.


Device management

client.revoke("agent-01")
client.unrevoke("agent-01")
client.remove("agent-01")
  • revoke → soft ban
  • unrevoke → restore
  • remove → hard delete

Environment-Based Setup

# export MACHINEID_ORG_KEY=org_123...
from machineid import MachineID

client = MachineID.from_env()

License

MIT – see LICENSE.

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

machineid_io-0.1.0.tar.gz (5.8 MB view details)

Uploaded Source

Built Distribution

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

machineid_io-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file machineid_io-0.1.0.tar.gz.

File metadata

  • Download URL: machineid_io-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for machineid_io-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ffe71e41d4dd6ff4edecc2917263207d18732bae8de514c1cb62c4aef7c7bab9
MD5 f63290c1421a536044153b173ab68a6b
BLAKE2b-256 9f4e5f41a4e9a1b6457f59a7db3d83787db6eb1ea7d8d58e3efbcf09b019aba4

See more details on using hashes here.

File details

Details for the file machineid_io-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: machineid_io-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for machineid_io-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f58596c607a249c6352e0f2b0381e28d4373dbdecf1d6ed54846889acb437bc1
MD5 05a971e5cb271e4e55277ba604d2d3cb
BLAKE2b-256 9eb730d9b8df3c9a8b59b36ee0d1dae035b3ddebdefc778cff534f79c3f05350

See more details on using hashes here.

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