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.1.tar.gz (58.1 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.1-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: argos_python-1.0.1.tar.gz
  • Upload date:
  • Size: 58.1 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.1.tar.gz
Algorithm Hash digest
SHA256 58d70214c0bf8767795f60b9338fe593d4a8d48091e67d7b2aa1d7419c8d7cec
MD5 a5bc37c1f0223e43bc6033c625f3657c
BLAKE2b-256 8d6d37860ec26fb730e1da82a2eff4b13e9681060d669b30bdecf15dcafaa866

See more details on using hashes here.

File details

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

File metadata

  • Download URL: argos_python-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 20.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 277dd46675a0f050b698fee3fb3e99b060240713c2253fd61acbbcf64963ce97
MD5 3661637727877bc7ae93b1a0c9d8fb9a
BLAKE2b-256 721fd533f425c9f2f3b6114a9dcd7915bdc7673d05f731b13632504180772bf2

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