x402 paywall for AI agent traffic. Python SDK + proxy for FastAPI, Flask, Django, Starlette.
Project description
limen (Python)
x402 paywall middleware + standalone proxy for Python. USDC on Base and Solana. Drop-in for FastAPI, Flask, Django, Starlette.
Install
pip install limen
# With optional framework extras:
pip install "limen[fastapi]"
pip install "limen[django]"
pip install "limen[flask]"
Python 3.11+.
FastAPI quickstart
import os
from fastapi import FastAPI
from limen.fastapi import LimenMiddleware
app = FastAPI()
app.add_middleware(
LimenMiddleware,
wallets={"base": os.environ["LIMEN_WALLET_BASE"]},
endpoints=[
{"path": "/api/v1/weather/*", "price_usdc": "0.001"},
{"path": "/api/v1/premium/**", "price_usdc": "0.05"},
],
redis_url=os.environ["REDIS_URL"],
)
@app.get("/api/v1/weather/{city}")
def weather(city: str) -> dict:
return {"city": city, "temp_c": 17}
Flask
from flask import Flask
from limen.flask import limen_middleware
app = Flask(__name__)
app.wsgi_app = limen_middleware(
app.wsgi_app,
wallets={"base": os.environ["LIMEN_WALLET_BASE"]},
endpoints=[{"path": "/api/v1/*", "price_usdc": "0.001"}],
redis_url=os.environ["REDIS_URL"],
)
Django
settings.py:
MIDDLEWARE = [
"limen.django.LimenMiddleware",
# ...
]
LIMEN = {
"wallets": {"base": os.environ["LIMEN_WALLET_BASE"]},
"endpoints": [{"path": "/api/v1/*", "price_usdc": "0.001"}],
"redis_url": os.environ["REDIS_URL"],
}
Standalone proxy
limen start --config limen.config.yml --upstream http://localhost:3000
CLI
limen start Run the proxy.
limen doctor Check config + connectivity + ports.
limen verify Verify a transaction against config.
limen config lint | print | explain | migrate
limen keys generate-webhook-secret | generate-admin-keypair
limen audit verify | tail
Security
This package enforces the nine invariants listed in docs/security.md § 4. Report vulnerabilities privately — see SECURITY.md.
Full getting-started, API reference, scaling, compliance docs:
../../docs/.
Development
hatch env create
hatch run test # pytest with coverage
hatch run lint # ruff
hatch run typecheck # mypy strict
License
MIT — see LICENSE.
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 limenpay-0.1.0a2.tar.gz.
File metadata
- Download URL: limenpay-0.1.0a2.tar.gz
- Upload date:
- Size: 43.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45c8e830287c22df0850ac98f787f7cbed37eb705c295559b1bf4c502bf34137
|
|
| MD5 |
a7e370b16361fc43c9adeae292b63f83
|
|
| BLAKE2b-256 |
1e9c11093e65716e354706a6827cb7bb21d3f6c874071104a823cf29f6010e59
|
File details
Details for the file limenpay-0.1.0a2-py3-none-any.whl.
File metadata
- Download URL: limenpay-0.1.0a2-py3-none-any.whl
- Upload date:
- Size: 55.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10abccbd8ea450b98f3409a2fd107c1f3bd16f160fde8943765c69774dc8a080
|
|
| MD5 |
0858d5366af6ea75193b5d6c96357397
|
|
| BLAKE2b-256 |
bfd000727c212353f50974daadb52886cc819bee2956e73e064a8c18cc799a93
|