FastAPI middleware for x402 payments -- consumer and provider
Project description
payskill-fastapi
FastAPI middleware for x402 payments — both consumer and provider sides.
Install
pip install payskill-fastapi
Provider — Gate a route behind an x402 paywall
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
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file payskill_fastapi-0.1.0.tar.gz.
File metadata
- Download URL: payskill_fastapi-0.1.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67d9080fd9c8f4a0b0d584201dd8c813e90d5256b214832ba97a1b44690b944a
|
|
| MD5 |
95a15b9892afa102f6acd48bd4caf171
|
|
| BLAKE2b-256 |
597987b62075bf47682cae52a8db7119e71083f673c111f24fd50f05a5a36885
|
Provenance
The following attestation bundles were made for payskill_fastapi-0.1.0.tar.gz:
Publisher:
release.yml on pay-skill/pay-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
payskill_fastapi-0.1.0.tar.gz -
Subject digest:
67d9080fd9c8f4a0b0d584201dd8c813e90d5256b214832ba97a1b44690b944a - Sigstore transparency entry: 1311766177
- Sigstore integration time:
-
Permalink:
pay-skill/pay-sdk@37347c8b305a855b01e659268e2668403f2ed5b1 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/pay-skill
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@37347c8b305a855b01e659268e2668403f2ed5b1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file payskill_fastapi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: payskill_fastapi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc8dfa72aaa95f9b4cf5fe399df4514827b022eca1ca59599418ddd5a34e184a
|
|
| MD5 |
0b3dd7ab663cfa6cff4a29f529e1ce9d
|
|
| BLAKE2b-256 |
0a0c10f274bb179b12a23baef160a6baf5467a7fb8fac443c18de955eeac7268
|
Provenance
The following attestation bundles were made for payskill_fastapi-0.1.0-py3-none-any.whl:
Publisher:
release.yml on pay-skill/pay-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
payskill_fastapi-0.1.0-py3-none-any.whl -
Subject digest:
dc8dfa72aaa95f9b4cf5fe399df4514827b022eca1ca59599418ddd5a34e184a - Sigstore transparency entry: 1311766284
- Sigstore integration time:
-
Permalink:
pay-skill/pay-sdk@37347c8b305a855b01e659268e2668403f2ed5b1 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/pay-skill
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@37347c8b305a855b01e659268e2668403f2ed5b1 -
Trigger Event:
push
-
Statement type: