Skip to main content

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 from the nested data payload
        event_data = verified_event.get("data", {})
        entity_reference = event_data.get("user_id") # Returns "document_reference_ref_5548"
        risk_level = event_data.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aeglis-1.0.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

aeglis-1.0.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file aeglis-1.0.2.tar.gz.

File metadata

  • Download URL: aeglis-1.0.2.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

Hashes for aeglis-1.0.2.tar.gz
Algorithm Hash digest
SHA256 9240b0f19ebe902e44fbe6eac24b75a9f47c607a2a36c3c28290caccad753ba0
MD5 4860175e991044ea8cf43a58250dc7e0
BLAKE2b-256 21fcbfe19b8bef01d0630ce9fb421d11486d27a6dc500ab9f8576ed77b481935

See more details on using hashes here.

File details

Details for the file aeglis-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: aeglis-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for aeglis-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0a9a129ce8500aebc61ce4abbb9c4ace3e1c724bd53dc1f705919d43763b9146
MD5 7c18f12166838b5eee1568aa28f2419e
BLAKE2b-256 06ce6652a1714c3a19d8fbec267957cdd67d8378d233945124162fe6c4ee9095

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