Metadata-Version: 2.4
Name: agent-attribution-protocol
Version: 0.1.0
Summary: Python SDK for the Agent Attribution Protocol (AAP) — AI agent affiliate attribution
Project-URL: Homepage, https://affili.ai
Project-URL: Repository, https://github.com/Affili-AI/aap-python
Project-URL: Specification, https://github.com/Affili-AI/aap-spec
Author-email: Affili AI <hello@affili.ai>
License-Expression: Apache-2.0
Keywords: aap,affiliate,agent,ai,attribution,commerce,mcp,protocol
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Requires-Dist: httpx>=0.25
Description-Content-Type: text/markdown

# agent-attribution-protocol

> Python SDK for the Agent Attribution Protocol (AAP)

AAP enables AI agents to discover offers, make recommendations, and earn commission when those recommendations lead to purchases.

## Install

```bash
pip install agent-attribution-protocol
```

## Quick Start

```python
from agent_attribution_protocol import AAP

aap = AAP(api_key="your-api-key")

# Search for offers
result = aap.search(vertical="sim", max_price=10, contract_months=0)
print(f"Found {result.count} offers")

# Recommend an offer (records attribution)
rec = aap.recommend(
    session_id=result.session_id,
    offer_id=result.offers[0].id,
    context="User asked for cheap SIM with no contract",
)
print(f"Recommendation recorded: {rec.recommendation_id}")
print(f"Fallback URL: {rec.fallback_url}")

# Initiate checkout
checkout = aap.checkout(
    session_id=result.session_id,
    recommendation_id=rec.recommendation_id,
)
print(f"Transaction: {checkout.transaction_id} ({checkout.status})")
```

## API

### `AAP(api_key, base_url="https://api.affili.ai")`

Create a client. Can also be used as a context manager:

```python
with AAP(api_key="your-key") as aap:
    result = aap.search(vertical="sim")
```

### `aap.search(**kwargs) → SearchResult`

| Parameter | Type | Description |
|-----------|------|-------------|
| `vertical` | str | `sim`, `broadband`, `energy`, `flights`, `hotels`, `insurance` |
| `provider` | str | Filter by provider name |
| `max_price` | float | Maximum price |
| `min_data_gb` | int | Minimum data (SIM) |
| `contract_months` | int | Contract length (0 = rolling) |

### `aap.recommend(session_id, offer_id, context=None) → Recommendation`

Record a recommendation. **This is the attribution event.**

### `aap.checkout(session_id, recommendation_id, user_details=None) → CheckoutResult`

Initiate checkout.

### `aap.get_session(session_id) → Session`

Get session details.

### `aap.verify_code(code) → dict`

Verify an AAP Code is authentic.

## Links

- 🌐 [affili.ai](https://affili.ai)
- 📄 [Protocol Spec](https://github.com/Affili-AI/aap-spec)
- 📦 [JS/TS SDK](https://github.com/Affili-AI/aap-js)
- 🔌 [MCP Server](https://github.com/Affili-AI/aap-mcp)

## Licence

Apache 2.0
