Metadata-Version: 2.4
Name: fingerprintiq
Version: 0.2.0
Summary: Official Python SDK for FingerprintIQ — visitor identification, API caller classification, and CLI usage analytics
Project-URL: Homepage, https://fingerprintiq.com
Project-URL: Documentation, https://docs.fingerprintiq.com
Project-URL: Repository, https://github.com/fingerprintiq/python
Project-URL: Issues, https://github.com/fingerprintiq/python/issues
Project-URL: Changelog, https://docs.fingerprintiq.com/changelog
Author-email: FingerprintIQ <hello@fingerprintiq.com>
License: MIT License
        
        Copyright (c) 2026 FingerprintIQ
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: ai-agent-detection,bot-detection,cli-analytics,fingerprint,machine-fingerprint,visitor-identification
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
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: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx>=0.27
Requires-Dist: psutil>=5.9
Provides-Extra: dev
Requires-Dist: fastapi>=0.100; extra == 'dev'
Requires-Dist: httpx>=0.27; extra == 'dev'
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: respx>=0.21; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Requires-Dist: starlette>=0.27; extra == 'dev'
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.100; extra == 'fastapi'
Requires-Dist: starlette>=0.27; extra == 'fastapi'
Description-Content-Type: text/markdown

# fingerprintiq

[![PyPI](https://img.shields.io/pypi/v/fingerprintiq.svg)](https://pypi.org/project/fingerprintiq/)
[![Python](https://img.shields.io/pypi/pyversions/fingerprintiq.svg)](https://pypi.org/project/fingerprintiq/)
[![Downloads](https://img.shields.io/pypi/dm/fingerprintiq.svg)](https://pypi.org/project/fingerprintiq/)
[![License](https://img.shields.io/pypi/l/fingerprintiq.svg)](./LICENSE)

Official Python SDK for [FingerprintIQ](https://fingerprintiq.com) — three products in one package:

- **Identify** — server-side visitor lookup
- **Sentinel** — classify API callers as browsers, AI agents, CLI tools, or bots
- **Pulse** — CLI usage analytics and machine fingerprinting

Links: [Docs](https://docs.fingerprintiq.com) · [PyPI](https://pypi.org/project/fingerprintiq/) · [Issues](https://github.com/fingerprintiq/python/issues)

## Installation

```bash
pip install fingerprintiq              # core (Identify + Sentinel + Pulse)
pip install 'fingerprintiq[fastapi]'   # + FastAPI / Starlette middleware
```

Requires Python 3.9+.

## Identify — server-side visitor lookup

```python
from fingerprintiq import FingerprintIQ

with FingerprintIQ(api_key="fiq_live_...") as client:
    visitor = client.lookup(visitor_id="iq_abc123")
    print(visitor.visitor_id, visitor.bot_probability)
```

Async variant:

```python
import asyncio
from fingerprintiq import FingerprintIQ

async def main() -> None:
    client = FingerprintIQ(api_key="fiq_live_...")
    try:
        visitor = await client.alookup(visitor_id="iq_abc123")
        print(visitor.bot_probability)
    finally:
        await client.aclose()

asyncio.run(main())
```

## Sentinel — FastAPI middleware

```python
from fastapi import FastAPI, Request
from fingerprintiq.sentinel.fastapi import SentinelMiddleware

app = FastAPI()
app.add_middleware(
    SentinelMiddleware,
    api_key="fiq_live_...",
    mode="blocking",
    timeout=1.0,
)

@app.get("/api/data")
def handler(request: Request):
    result = request.state.sentinel  # SentinelResult | None
    if result and result.caller_type == "bot":
        return {"blocked": True}
    return {"ok": True}
```

The default middleware mode is `"background"` so FingerprintIQ inspection does not add network latency to the request path. Use `mode="blocking"` only when the handler needs `request.state.sentinel` before responding.

## Pulse — CLI analytics

```python
from fingerprintiq.pulse import Pulse

pulse = Pulse(api_key="fiq_live_...", tool="my-cli", version="1.2.3")
pulse.track("deploy", metadata={"duration_ms": 1234, "success": True})
pulse.shutdown()  # or let atexit handle it
```

Honors `DO_NOT_TRACK=1` and `FINGERPRINTIQ_OPTOUT=1` out of the box. Set `respect_opt_out=False` to override.

## Sibling Packages

| Package | Purpose |
|---------|---------|
| [`fingerprintiq`](https://pypi.org/project/fingerprintiq/) (PyPI) | Python SDK — Identify, Sentinel, Pulse (this package) |
| [`@fingerprintiq/js`](https://www.npmjs.com/package/@fingerprintiq/js) | Browser fingerprinting |
| [`@fingerprintiq/server`](https://www.npmjs.com/package/@fingerprintiq/server) | Server-side caller classification (Hono, Express) |
| [`@fingerprintiq/pulse`](https://www.npmjs.com/package/@fingerprintiq/pulse) | Node CLI usage analytics |

## Contributing

This repo is a **read-only public mirror**. The master copy lives in the private FingerprintIQ monorepo and is synced here on every push to `main`. Please [file issues](https://github.com/fingerprintiq/python/issues) rather than PRs.

## License

MIT
