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",
# Response Key from Dashboard -> Products -> Response Key. Without this,
# validate()/activate() refuse to trust any response (fail closed) -
# see the Security section below.
response_auth_key="YOUR-RESPONSE-KEY-BASE64",
)
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",
response_auth_key="YOUR-RESPONSE-KEY-BASE64",
)
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
Security - Response Integrity
Every /validate response is signed by the server with
X-AstraGuard-Signature: sha256=<hex>, an HMAC-SHA256 over the exact response
body. Pass response_auth_key at construction time with the Response Key from
Dashboard -> Products -> Security -> Response Key to enable verification
(shown in both quick-start examples above).
- Fail-closed: without a configured key,
validate()/activate()never trust a response - they raiseSignatureMismatchinstead of silently treating an unsigned reply as valid. - Whole-body coverage: the signature check covers the entire response - features, cloud variables, security flags, everything - so a man-in-the-middle can't quietly alter a value in transit.
- Server-side secret: the Response Key must stay on the server - never send it to a browser or embed it in a distributed client. This SDK is already server-only (see the notice at the top of this README), so this is the natural place for it to live.
Heartbeat
import sys
client.start_heartbeat(
license_key="XXXX-XXXX-XXXX-XXXX",
interval=300,
on_lapse=lambda: sys.exit(1),
)
License
MIT
Links
- Docs: https://docs.astraguard.io
- Dashboard: https://www.astraguard.io/dashboard
- Discord (live help): https://discord.gg/Zkcyy5GnQd
- Email: support@astraguard.io
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file astraguard-1.3.0.tar.gz.
File metadata
- Download URL: astraguard-1.3.0.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7f03d9c388ef8eebd3f7001b039b11e2bfd952d618a81c6e6045225732a9e98
|
|
| MD5 |
7a34b520762c5f79a0a3557c64e7631f
|
|
| BLAKE2b-256 |
8baf6eb6e9b8519775c20b61595e407178cc99659ca4d9a3458af7b0f9d4bc2d
|
File details
Details for the file astraguard-1.3.0-py3-none-any.whl.
File metadata
- Download URL: astraguard-1.3.0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62fb43c84fb8d888965b1c90691daa23e90ede6eed84e737382aae208819a349
|
|
| MD5 |
29eac1798a9046b78e9b3c979a50f0bf
|
|
| BLAKE2b-256 |
2942cfc7ca69b02898b301bd37a54f8bb003de03122e90d24430e3d95684b830
|