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

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.0.tar.gz (13.1 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.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: astraguard-1.2.0.tar.gz
  • Upload date:
  • Size: 13.1 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.0.tar.gz
Algorithm Hash digest
SHA256 7e2eda5c3d99fc7c685fed8b2140f8bf7e9bbfc10c114661568e94fa4b46cbe5
MD5 e44c93d988d94fc1c426ea68ebcf50f7
BLAKE2b-256 91a08722f7c47da1c434f1d226ea4da9c493bbf51b091e8e425dbb9614b3b0ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: astraguard-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 128f170066e9547e2bea31359ec481880954346102adf2e096a081ad3aa8a7bd
MD5 eee5070ce822933d0b6ee4097f280822
BLAKE2b-256 ef2bf4afa8a260cc1221703c753f22ce4bed9341c37bd156308e0da8ea9aff01

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