Metadata-Version: 2.4
Name: payskill-fastapi
Version: 0.1.0
Summary: FastAPI middleware for x402 payments -- consumer and provider
Project-URL: Homepage, https://pay-skill.com
Project-URL: Repository, https://github.com/pay-skill/pay-sdk
Author-email: "Agent Payment Protocol Infrastructure Inc." <hello@pay-skill.com>
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: FastAPI
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Office/Business :: Financial
Requires-Python: >=3.10
Requires-Dist: fastapi>=0.100
Requires-Dist: httpx>=0.27
Requires-Dist: pay-skill>=0.1.14
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest-timeout>=2.3; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Requires-Dist: uvicorn>=0.30; extra == 'dev'
Description-Content-Type: text/markdown

# payskill-fastapi

FastAPI middleware for x402 payments — both consumer and provider sides.

## Install

```bash
pip install payskill-fastapi
```

## Provider — Gate a route behind an x402 paywall

```python
from fastapi import FastAPI, Depends
from payskill_fastapi import require_payment, PaymentInfo

app = FastAPI()

@app.get("/api/data")
async def get_data(
    payment: PaymentInfo = Depends(
        require_payment(
            price=0.01,
            settlement="tab",
            provider_address="0x...",
        )
    ),
):
    return {"data": "premium", "paid_by": payment.from_address}
```

## Consumer — Auto-pay outbound x402 calls

```python
from fastapi import FastAPI, Request
from payskill import Wallet
from payskill_fastapi import PayMiddleware

app = FastAPI()
wallet = Wallet()

app.add_middleware(PayMiddleware, wallet=wallet, max_per_request=1.00)

@app.get("/forecast")
async def forecast(request: Request):
    resp = request.state.pay.fetch("https://api.example.com/forecast")
    return resp.json()
```

## License

MIT
