Official Python SDK for the Aeglis Security API
Project description
Aeglis Python SDK
The official Python SDK for Aeglis — The Hybrid AI Security Engine. Protect your application backend from zero-day phishing, malicious payloads, and embedded macro-viruses in real-time. Built specifically for high-throughput enterprise environments, FinTech APIs, and data science infrastructure.
Installation
Install the package from PyPI using pip:
pip install aeglis
Quick Start
Retrieve your API Key and Webhook Secret from the Aeglis Developer Dashboard.
from aeglis import Aeglis
# Initialize the secure client instance
client = Aeglis(api_key="sk_live_YourApiKeyHere")
Core API Methods
1. Quick Scan (Synchronous)
Best for evaluation of short text inputs, chat moderation, and processing outbound marketing links.
try:
response = client.scan(
input_text="Claim your free reward at [http://suspicious-link.com](http://suspicious-link.com)",
end_user_id="user_id_9982" # Optional internal tracking reference
)
print(response["status"]) # "success"
print(response["data"]["risk_level"]) # "DANGER", "WARNING", or "SAFE"
except Exception as e:
print(f"Scanning failed: {e}")
2. Deep File Scan (Asynchronous)
Best for user document uploads, KYC verification pipelines, and large file extraction (up to 50MB). Note: This operations fires a background worker thread. The final granular security report will be pushed to your configured Webhook endpoint.
try:
response = client.deep_scan(
file_path="./uploads/user_resume.pdf",
input_text="Contextual document upload for review", # Optional
end_user_id="document_ref_5548" # Optional reference mapped back in webhook
)
print(response["status"]) # "processing"
print(response["message"]) # "File accepted. Result will be dispatched to your Webhook."
except Exception as e:
print(f"Deep scan upload failed: {e}")
Webhook Verification (Security)
Aeglis dispatches scanning outputs asynchronously via HTTP POST. To maintain integrity and avoid payload interception or spoofing, you must verify the inbound cryptographic HMAC SHA-256 signature.
The SDK compresses this validation execution into a single method.
⚠️ CRITICAL INTEGRATION NOTICE: Signature verification strictly requires the raw, unparsed request body bytes. If your framework maps incoming streams directly into a parsed dictionary, cryptographic calculation will mismatch due to whitespace normalization.
FastAPI Production Implementation Example:
from fastapi import FastAPI, Request, HTTPException
from aeglis import Aeglis, AeglisError
app = FastAPI()
client = Aeglis(api_key="sk_live_YourApiKeyHere")
WEBHOOK_SECRET = "whsec_YourDashboardSecretHere"
@app.post("/v3/aeglis-callback")
async def handle_security_webhook(request: Request):
# 1. Capture the raw unparsed request body bytes
raw_payload = await request.body()
# 2. Extract the signature header
signature_header = request.headers.get("x-aeglis-signature")
try:
# 3. Securely verify signature using timing attack protections
verified_event = client.verify_webhook(
raw_payload=raw_payload,
signature_header=signature_header,
webhook_secret=WEBHOOK_SECRET
)
# Extract metadata and routing flags
entity_reference = verified_event.get("user_id") # Returns "document_ref_5548"
risk_level = verified_event.get("risk_level")
if risk_level == "DANGER":
# Execute internal system quarantine logic using the reference
pass
return {"status": "processed"}
except AeglisError as e:
# Prevent tracking parameter leakage on failure responses
raise HTTPException(status_code=400, detail="Invalid signature verification failed.")
Exception Handling
The SDK exposes granular API errors via custom exceptions. Use standard Python try-except blocks to catch runtime anomalies cleanly.
from aeglis import Aeglis, AeglisError
client = Aeglis(api_key="sk_live_YourApiKeyHere")
try:
client.scan(input_text="") # Empty string payload violation
except ValueError as e:
print(f"Validation Error: {e}")
except AeglisError as e:
print(f"API Error Boundary Hit: {e}")
Resources
Project details
Release history Release notifications | RSS feed
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 aeglis-1.0.1.tar.gz.
File metadata
- Download URL: aeglis-1.0.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
358682179efabf6389079d7afcf3c837f36ce4148b7165cd454774c02c891767
|
|
| MD5 |
c6d2d88aa0a3022e408fbad8d81275c0
|
|
| BLAKE2b-256 |
26573b11e47d3d1f2baba837b7db461e546d4e0847a79ddf26f072b6c4a4175a
|
File details
Details for the file aeglis-1.0.1-py3-none-any.whl.
File metadata
- Download URL: aeglis-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7998ba80a15392cab37b61b355ed094692c50ca6e0d71d897d68c022a0445839
|
|
| MD5 |
92c4bd83073f324151f5efdf842d65d4
|
|
| BLAKE2b-256 |
7c694d01911b371b0b6256b4f50d37d7667b4d912c1b39a0409b36d348e8bd56
|