Skip to main content

Official AstraGuard SDK — license validation, HWID binding, and offline cache for Python server applications

Project description

astraguard

Official AstraGuard SDK for Python - license validation, HWID binding, and AES-256-GCM offline cache for server-side applications.

Server-Side Only This SDK is for Python server applications (Flask, FastAPI, Django, etc.). Do NOT embed it in client-side software - Python offers no meaningful anti-debug or anti-VM protection. For desktop protection use the C++ header or Rust SDK.

Installation

pip install astraguard

Async support (FastAPI, asyncio):

pip install "astraguard[async]"

Sync (Flask / Django)

from astraguard import AstraGuardClient

client = AstraGuardClient(
    api_url="https://api.astraguard.io",
    product_id="your-product-id",
)

result = client.validate("XXXX-XXXX-XXXX-XXXX")
if result.valid:
    print("License valid!")

Async (FastAPI)

from astraguard import AsyncAstraGuardClient

client = AsyncAstraGuardClient(
    api_url="https://api.astraguard.io",
    product_id="your-product-id",
)

result = await client.validate("XXXX-XXXX-XXXX-XXXX")

Features

  • validate() / activate() with fully typed responses
  • HMAC-SHA256 response verification (fail-closed)
  • AES-256-GCM encrypted offline cache (configurable grace period)
  • Background heartbeat thread
  • Cross-platform HWID (Windows registry, /etc/machine-id, IOPlatformUUID)
  • validate_or_exit() for CLI tools
  • has_feature() / get_variable() shortcuts
  • Update check via /check-update
  • Full type annotations + py.typed marker

Error Handling

from astraguard import NetworkError, ServerError, SignatureMismatch

try:
    result = client.validate(license_key)
except NetworkError:
    pass  # unreachable + no cache
except ServerError as e:
    print(f"HTTP {e.status}")
except SignatureMismatch:
    pass  # tampered response

Heartbeat

import sys

client.start_heartbeat(
    license_key="XXXX-XXXX-XXXX-XXXX",
    interval=300,
    on_lapse=lambda: sys.exit(1),
)

License

MIT

Links

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

astraguard-1.2.1.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

astraguard-1.2.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file astraguard-1.2.1.tar.gz.

File metadata

  • Download URL: astraguard-1.2.1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for astraguard-1.2.1.tar.gz
Algorithm Hash digest
SHA256 95a2885e9c02d864be0e80c2d78f2bee0974cd2b745faedc9203d8efb4debf10
MD5 a143cb5a02856ea5653882c33db0f882
BLAKE2b-256 8a5aa0c66fab0af0adaa5b208381ea7f0e7021694bafbeec01cb820196c8ea25

See more details on using hashes here.

File details

Details for the file astraguard-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: astraguard-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for astraguard-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1b613ed3b56ac7c07541168f3a100f8ee0cd2e348009eec883ce32270a5cabc
MD5 40201009240d1dd45ae8bd73729bcb7c
BLAKE2b-256 6270752f6e01f143e985ff7962d01a7b61d07e120bdb8d26a096aef2a82272c7

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