Skip to main content

argos Security SDK for Python

Project description

argos Security SDK

A production-grade Python SDK for real-time threat detection and fraud prevention. argos monitors every request, scores risk using ML, and lets you block threats instantly or asynchronously.

Features

  • AI-Powered Detection: ML models analyze requests in real-time
  • Zero Latency: Async mode queues events without blocking your app
  • Sync Enforcement: Block malicious requests before they reach your logic
  • Circuit Breaker: Built-in resilience with exponential backoff
  • Framework Middleware: Drop-in support for FastAPI, Flask, Django, Starlette

Installation

pip install argos

# With framework support
pip install argos[fastapi]    # FastAPI + Starlette
pip install argos[flask]     # Flask
pip install argos[django]     # Django
pip install argos[all]      # Everything

Quick Start

from argos import create_client

client = create_client(api_key="your-api-key")

event = client.ingest({
    "event_type": "login",
    "user_id": "user123",
    "ip_address": "192.168.1.1",
    "status": "success"
})

if event.signal == "BLOCK":
    print("Threat detected!")

With Middleware

FastAPI

from fastapi import FastAPI
from argos import create_client
from argos.middleware.fastapi import FastAPIMiddleware

app = FastAPI()
client = create_client(api_key="your-api-key")

app.add_middleware(FastAPIMiddleware, client=client, mode="async")

Flask

from flask import Flask
from argos import create_client
from argos.middleware.flask import FlaskMiddleware

app = Flask(__name__)
client = create_client(api_key="your-api-key")
FlaskMiddleware(app, client)

Django

Add to settings.py:

ARGOS_API_KEY = "your-api-key"

MIDDLEWARE = [
    ...
    'argos.middleware.django.DjangoMiddleware',
    ...
]

Configuration

from argos import create_client

client = create_client(
    api_key="your-api-key",
    timeout=30.0,
    max_retries=3,
    queue_size=1000,
    circuit_breaker_threshold=5,
    circuit_breaker_timeout=60.0,
)

Middleware Options

from argos.middleware.base import MiddlewareConfig

config = MiddlewareConfig(
    mode="async",              # "sync" to block, "async" to queue
    include_headers=True,       # include request headers in events
    exclude_paths=["/health"], # skip these paths
    identity_header="X-User-ID",
)

Error Handling

from argos import (
    argosError,
    argosAuthenticationError,
    argosRateLimitError,
    argosTimeoutError,
    argosCircuitOpenError,
)

try:
    event = client.ingest({...})
except argosAuthenticationError:
    print("Invalid API key")
except argosRateLimitError as e:
    print(f"Rate limited, retry in {e.retry_after}s")
except argosCircuitOpenError:
    print("argos is unavailable")

Async Usage

import asyncio
from argos import create_client

async def main():
    client = create_client(api_key="your-api-key")
    event = await client.aingest({"event_type": "login", "user_id": "user123"})
    print(event.signal)

asyncio.run(main())

High Throughput

Queue events during peak traffic, flush when convenient:

# Queue without blocking
for req in requests:
    client.queue_event({"event_type": "request", "path": req.url})

# Process queued events
events = client.flush_queue()

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

argos_python-1.0.2.tar.gz (56.8 kB view details)

Uploaded Source

Built Distribution

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

argos_python-1.0.2-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: argos_python-1.0.2.tar.gz
  • Upload date:
  • Size: 56.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for argos_python-1.0.2.tar.gz
Algorithm Hash digest
SHA256 af1644eec45b318fffa91258e3b5e0911fa8964153a7463ff97ab41b73d50616
MD5 5d0684f7436a9c06151bbe15d056c988
BLAKE2b-256 0b7b8cd90b5712b356c4546cf293009a674f200e90751368718b5ca8534645a4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: argos_python-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for argos_python-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 246c93628bae5e0fe3799572e2d814a3bf3cf7460d8d1b4344204b781098baff
MD5 00c95018136971bc0a8b76d9dee8260b
BLAKE2b-256 d2fb6e2cca2db985777ceaa13c05b3e6487d1ceafcc661ad8b9d7da5bf2f3e69

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