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.1.tar.gz (3.5 kB 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.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: machineid_io-0.1.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • 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.1.tar.gz
Algorithm Hash digest
SHA256 352b04285250eeb37a7b11f31703dc3a0516492e5980cf8aa63819e1ecaea392
MD5 cef950b364203632b7f361a34a830aa6
BLAKE2b-256 22f8ed860c8726f23fa57c6b961f88d876958a084e1b4eeb1bd46ce6adedf3a9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: machineid_io-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 62c1e9305f4c2028268052897cea581f38e41250a44e4184993e6cf22e23fc1f
MD5 00af6f0f5aa82efdb021bb356e953dbe
BLAKE2b-256 6d1035a8bbfdfffd44b3611bbd62bd093d32477df6e62e751c0929173c76f67e

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