Metadata-Version: 2.4
Name: deflect
Version: 0.1.0
Summary: Official Deflect Bot Protection SDK for Python
Author: Deflect
License: MIT
Project-URL: Homepage, https://docs.deflect.bot/
Project-URL: Source, https://github.com/deflectbot/deflect-python
Project-URL: Issues, https://github.com/deflectbot/deflect-python/issues
Keywords: deflect,bot,security,antibot
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Topic :: Security
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: httpx<0.28.0,>=0.27.0
Provides-Extra: async
Requires-Dist: httpx[http2]<0.28.0,>=0.27.0; extra == "async"
Provides-Extra: test
Requires-Dist: pytest>=6.0; extra == "test"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"

# Deflect Python SDK

Early Python SDK for the Deflect Bot Protection API (experimental).

## Installation

Install PyPi package:
```bash
pip install deflect
```

## Quick Start (Sync)
```python
from deflect import Deflect, DeflectOptions

client = Deflect(DeflectOptions(api_key="YOUR_KEY", action_id="YOUR_ACTION"))
verdict = client.get_verdict(user_session_token)
if verdict.get("verdict", {}).get("can_pass"):
    # allow
    ...
else:
    # block
    ...
```

## Quick Start (Async)
```python
import asyncio
from deflect import AsyncDeflect, DeflectOptions

async def main():
    client = AsyncDeflect(DeflectOptions(api_key="YOUR_KEY", action_id="YOUR_ACTION"))
    verdict = await client.get_verdict(user_session_token)
    print(verdict)

asyncio.run(main())
```

## Configuration
`DeflectOptions`:
- `api_key` (str, required)
- `action_id` (str, required)
- `base_url` (str, default `https://api.deflect.bot`)
- `timeout` (float seconds, default 4.0)
- `max_retries` (int, default 2)
- `client` / `async_client` (inject custom `httpx` client instances)

## Errors
Raises `DeflectError` with attributes:
- `status` (int | None)
- `body` (parsed JSON or None)

## Testing
```bash
pytest -q
```

## Roadmap
- Optional exponential backoff
- Type refinements when API spec expands
- Streaming / additional endpoints

## License
MIT
