Skip to main content

Adoaler Python SDK

PyPI version Python Support License: MIT

SDK oficial Python para integração com o Adoaler Security Platform.

Instalação

pip install adoaler

Requisitos

  • Python 3.8+
  • requests >= 2.28.0

Quick Start

from adoaler import Adoaler

# Inicializar cliente
client = Adoaler(
    api_key="sua_api_key",
    environment="production"  # ou "sandbox"
)

# Verificar risco de IP
result = client.ip.check("203.0.113.42")
print(f"Risk Score: {result.risk_score}")
print(f"Risk Level: {result.risk_level}")

# Verificar dispositivo
device_result = client.device.verify(
    fingerprint="device_fingerprint_hash",
    user_id="user_123"
)
print(f"Device Trust Score: {device_result.trust_score}")

Funcionalidades

IP Intelligence

# Verificação completa de IP
ip_info = client.ip.check("203.0.113.42")

# Propriedades disponíveis
ip_info.ip                  # IP verificado
ip_info.risk_score          # Score de risco (0-100)
ip_info.risk_level          # critical, high, medium, low
ip_info.is_vpn              # É VPN?
ip_info.is_proxy            # É proxy?
ip_info.is_tor              # É Tor?
ip_info.is_datacenter       # É datacenter?
ip_info.country             # País (ISO code)
ip_info.city                # Cidade
ip_info.asn                 # ASN
ip_info.organization        # Organização
ip_info.categories          # Categorias de ameaça

# Verificação em lote
ips = ["203.0.113.42", "198.51.100.23", "192.0.2.1"]
results = client.ip.check_batch(ips)

Device Fingerprinting

# Verificar dispositivo
device = client.device.verify(
    fingerprint="fp_hash_from_js_sdk",
    user_id="user_123",
    metadata={"session_id": "sess_abc"}
)

device.device_id            # ID único do dispositivo
device.trust_score          # Score de confiança (0-100)
device.is_known             # Dispositivo já visto?
device.bot_probability      # Probabilidade de ser bot

Bot Detection

bot_check = client.bot.detect(
    fingerprint="fp_hash",
    user_agent="Mozilla/5.0...",
    ip="203.0.113.42",
    behavior={
        "mouse_movements": 150,
        "keystrokes": 45,
        "time_on_page": 12.5
    }
)

bot_check.is_bot            # É bot?
bot_check.bot_type          # Tipo de bot
bot_check.confidence        # Confiança da detecção

Fraud Detection

fraud_check = client.fraud.check_transaction(
    transaction_id="txn_123",
    amount=199.99,
    currency="BRL",
    user_id="user_123",
    device_fingerprint="fp_hash",
    ip="203.0.113.42",
    email="user@example.com"
)

fraud_check.risk_score      # Score de risco (0-100)
fraud_check.recommendation  # approve, review, decline
fraud_check.signals         # Sinais de risco detectados

Integração com Frameworks

Flask

from flask import Flask
from adoaler.integrations.flask import AdoalerMiddleware

app = Flask(__name__)
app.wsgi_app = AdoalerMiddleware(
    app.wsgi_app,
    api_key="sua_api_key",
    block_high_risk=True
)

Django

# settings.py
MIDDLEWARE = [
    'adoaler.integrations.django.AdoalerMiddleware',
]

ADOALER = {
    'API_KEY': 'sua_api_key',
    'ENVIRONMENT': 'production',
}

FastAPI

from fastapi import FastAPI
from adoaler.integrations.fastapi import AdoalerMiddleware

app = FastAPI()
app.add_middleware(AdoalerMiddleware, api_key="sua_api_key")

Async Support

from adoaler import AsyncAdoaler

async def main():
    client = AsyncAdoaler(api_key="sua_api_key")
    result = await client.ip.check("203.0.113.42")
    await client.close()

Tratamento de Erros

from adoaler.exceptions import (
    AdoalerError,
    AuthenticationError,
    RateLimitError,
    ValidationError
)

try:
    result = client.ip.check("203.0.113.42")
except RateLimitError as e:
    print(f"Rate limit. Retry após: {e.retry_after}s")
except AuthenticationError:
    print("Chave de API inválida")
except AdoalerError as e:
    print(f"Erro: {e}")

Webhooks

from adoaler.webhooks import WebhookHandler

webhook = WebhookHandler(signing_secret="seu_webhook_secret")

@app.route("/webhook", methods=["POST"])
def handle_webhook():
    payload = request.get_data()
    signature = request.headers.get("X-Adoaler-Signature")
    
    event = webhook.verify_and_parse(payload, signature)
    
    if event.type == "threat.detected":
        handle_threat(event.data)
    
    return {"received": True}

Documentação

Suporte

Licença

MIT License - veja LICENSE para detalhes.

Metadata

Release files for adoaler-sdk 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adoaler-sdk 1.0.0
File Size Uploaded Provenance Actions
adoaler_sdk-1.0.0.tar.gz 27.4 kB Without provenance Details for adoaler_sdk-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for adoaler-sdk 1.0.0
File Interpreter ABI Platform Actions
adoaler_sdk-1.0.0-py3-none-any.whl Python 3 none any Details for adoaler_sdk-1.0.0-py3-none-any.whl

Total release size: 56.0 kB

Release files / adoaler_sdk-1.0.0.tar.gz

Download URL adoaler_sdk-1.0.0.tar.gz
Size 27.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7a1f02d04a4ba4ba5fa1bea957a2877fddad0caf5143aeddb80617e8e6117c53
BLAKE2b-256 checksum
How to use checksums
6c5483b9acd9436ee2c94e25758fa4b505ac33911d242359d9fcae2aa73fc48d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / adoaler_sdk-1.0.0-py3-none-any.whl

Download URL adoaler_sdk-1.0.0-py3-none-any.whl
Size 28.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b6f87a5c68faf9c459d6df354b77d2f06da373ca82ea0a9538c2ece9d1670dc
BLAKE2b-256 checksum
How to use checksums
a1eda2d50f5aabec9947fc075e4254c03ac0861d798213f247f937ea69c78164
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Security for adoaler-sdk 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page