Skip to main content

argos Security SDK for Python

Project description

Argos Security SDK

PyPI Version Python Versions License: MIT

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


🚀 Features

  • AI-Powered Detection: ML models analyze requests in real-time and return risk scores.
  • Zero-Latency Ingestion: Background worker automatically flushes event queues without blocking your application.
  • Smart Caching: Built-in TTL caching for blocklist checks ensures sub-millisecond response times for repeated IPs.
  • Framework Middleware: Drop-in middleware for FastAPI, Flask, Django, and Starlette.
  • Resilient Design: Built-in Circuit Breaker and Retry logic with exponential backoff.
  • Zero Dependencies: Core SDK uses only the Python standard library.

📦 Installation

pip install argos-python

# With framework support
pip install argos-python[fastapi]    # FastAPI + Starlette
pip install argos-python[flask]      # Flask
pip install argos-python[django]     # Django
pip install argos-python[all]        # All frameworks

⚡ Quick Start

import atexit
from argos import create_client

# Initialize the client
client = create_client(api_key="your-api-key")

# Ensure clean shutdown and final flush
atexit.register(client.close)

# Ingest an event for analysis
event = client.ingest({
    "event_type": "login",
    "user_id": "user123",
    "status": "success"
})

# Check the verdict
if event.signal == "BLOCK":
    print("Threat detected! Block this request.")

🛠️ Configuration

Creating a Client

from argos import create_client

client = create_client(
    api_key="your-api-key",
    base_url="https://argos-api.tachyonix.net",
    
    # Reliability
    max_retries=3,                   # Max retry attempts
    circuit_breaker_threshold=5,     # Failures before opening circuit
    
    # Performance & Locality
    blocklist_cache_ttl=60.0,        # Cache blocklist results for 60s
    flush_interval=1.0,              # How often to flush background queue (seconds)
    batch_size=50,                   # Max events per batch flush
    
    # Behavior
    auto_block_on_block=False,       # Auto-block IP on BLOCK verdict
)

Configuration Options

Option Default Description
api_key Required Your Argos API key
base_url https://... Base URL of the Argos API
sync_mode False If True, disables background flushing (all ingestions block)
blocklist_cache_ttl 60.0 Time-to-live for local blocklist cache (seconds)
flush_interval 1.0 Frequency of background queue flushing (seconds)
batch_size 50 Maximum events per batch ingestion
max_retries 3 Maximum retry attempts for failed requests
circuit_breaker_threshold 5 Failures before temporarily suspending requests

🧩 Middleware Integration

FastAPI / Starlette

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

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

app.add_middleware(FastAPIMiddleware, client=client, config=MiddlewareConfig(
    mode="async",                    # "sync" blocks requests, "async" queues
    include_body=True,               # Include request body in events
    exclude_paths=["/static"],       # Paths to skip
))

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, mode="sync") # Blocks bad requests immediately

🛡️ Blocklist Management

Argos provides a powerful programmatic blocklist that is synced to your local application cache for maximum performance.

# Check if an IP is blocked (uses local cache)
is_blocked, reason = client.is_blocked("192.168.1.1")

# Programmatically block a user
client.block_user("user123", environment_id="env_123", reason="Suspicious behavior")

# Unblock instantly
client.unblock(entry_id="...")

📖 Advanced Usage

Manual Queue Management

While the SDK flushes events in the background by default, you can still queue events manually for specific logic:

client.queue_event({"event_type": "nav"}, metadata={"path": "/home"})
# Background worker will pick this up automatically!

Clean Shutdown

Always call client.close() or register it with atexit to ensure all queued events are sent before your process exits.

import atexit
atexit.register(client.close)

📄 License

MIT License - see LICENSE for details.

🤝 Contributing

We welcome contributions! Please see our CONTRIBUTING.md for philosophy and coding guidelines.

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.2.0.tar.gz (63.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.2.0-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: argos_python-1.2.0.tar.gz
  • Upload date:
  • Size: 63.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.2.0.tar.gz
Algorithm Hash digest
SHA256 cd36db43c1b04b74c8ec5a13f1be9bc47f95baec989c4f9b210a06135dec786c
MD5 600dccb0b8e87cd9beac6efced744b07
BLAKE2b-256 2aff97356dbfa60e55c996542d54162a93a70cc3d32c526678f42cf4e4314ce4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: argos_python-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 30.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 203c38dd2f580d5afc241a2923247c13a37e2813fb28d09120d1635fe3273468
MD5 8579cd2ea33f9ef2a3c1dce267994881
BLAKE2b-256 9f3962062d615b6ec9a3afde4266c4b436406ec563bc63d1188157505517e30b

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