Solinkify Gate for Python — block AI scrapers with an HTTP 402 paywall, monetize ethical AI agents on Solana. WSGI (Django/Flask) + ASGI (FastAPI/Starlette) middleware.
Project description
solinkify-gate (Python)
Solinkify Gate for Python — block AI scrapers with an HTTP 402 paywall
(manifest aligned with the x402 standard) and monetize ethical AI agents on
Solana. A port of @solinkify/gate (JS). Zero dependencies (stdlib only).
Works with: Flask · Django · FastAPI · Starlette · Bottle · Pyramid · Quart (anything WSGI/ASGI).
Install
pip install solinkify-gate
1. Register your endpoint (once)
Open https://solinkify.com/gate/setup, connect a wallet, register an
endpoint_id + a price per request (USDC).
2. Add the middleware (1-paste)
Flask / any WSGI
from solinkify_gate import GateConfig
from solinkify_gate.wsgi import SolinkifyGateMiddleware
app.wsgi_app = SolinkifyGateMiddleware(app.wsgi_app, GateConfig(
wallet="<CREATOR_WALLET>",
price=0.001, # USDC per request
endpoint_id="my-site",
))
Django (project/wsgi.py)
from django.core.wsgi import get_wsgi_application
from solinkify_gate import GateConfig
from solinkify_gate.wsgi import SolinkifyGateMiddleware
application = SolinkifyGateMiddleware(get_wsgi_application(), GateConfig(
wallet="<CREATOR_WALLET>", price=0.001, endpoint_id="my-site",
))
FastAPI / Starlette (ASGI)
from solinkify_gate import GateConfig
from solinkify_gate.asgi import SolinkifyGateMiddleware
app.add_middleware(SolinkifyGateMiddleware, config=GateConfig(
wallet="<CREATOR_WALLET>", price=0.001, endpoint_id="my-site",
))
Done. AI scrapers (GPTBot, ClaudeBot, PerplexityBot, and 40+ others) get a 402 + payment manifest; humans & search engines (Googlebot/Bingbot) pass through normally (SEO-safe by default); ethical agents pay via Solana escrow and are verified on-chain.
Configuration (GateConfig)
| Field | Default | Description |
|---|---|---|
wallet |
— | Creator wallet (required) |
price |
— | Price per request, token units (required) |
endpoint_id |
"" |
On-chain endpoint from setup |
token_mint |
USDC mainnet | Settlement stablecoin mint |
api_url |
https://api.solinkify.com |
Verification backend |
protected_paths |
["/*"] |
Glob: exact, /*, /prefix/* |
exclude_paths |
[] |
Always let through |
detection |
"basic" |
"basic" (SEO-safe) / "strict" |
allow_bots |
[] |
Bot-name whitelist (e.g. ["Googlebot"]) |
free_requests |
0 |
Freemium: N free requests per client per day |
tiers |
[] |
GateTier(pattern, endpoint_id, price) per-path pricing |
license |
None |
{"url","terms","attribution"} → manifest + discovery |
analytics |
True |
Ping the analytics dashboard (fire-and-forget) |
trust_proxy |
True |
Trust x-forwarded-for/x-real-ip; set False when the app takes direct connections |
verify_bot_ips |
True |
Verify the client IP against the bot's official ranges (Google/Bing). A "Googlebot" from a fake IP → paywall; unverifiable → normal behaviour (safe) |
Parity with the JS SDK
- 402 manifest aligned with x402 (
x402Version,accepts[]) + backward-compat. - Automatic
/.well-known/solinkifydiscovery document. - Tiered/per-path pricing, freemium metering (fail-closed), analytics ping.
- Bot IP verification (
verify_bot_ips): an impostor "Googlebot" from a non-Google IP never gets the SEO free-pass — parity with the JS core. - Pre-paid & subscription (no per-request tx): the manifest/discovery
advertise
access_modes; an agent withx-solinkify-payer+x-solinkify-prepaidheaders (the backend debits its on-chain balance, fail-closed) orx-solinkify-subscription(while unexpired) is let through automatically — no extra middleware config. - Fail-open: a Gate bug never takes the creator's site down.
Note: the more aggressive strict+ anti-abuse layers (headless-browser
heuristics, datacenter-IP blocking) are for now only in the JS SDK
@solinkify/gate.
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 solinkify_gate-0.2.0.tar.gz.
File metadata
- Download URL: solinkify_gate-0.2.0.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
603cec6ac7f768d9f2460664f770be262bbed97f19fae7c22e1b3ac8173ec075
|
|
| MD5 |
1bf01c0fa202842672f1a8168ea07bd0
|
|
| BLAKE2b-256 |
23712555926bb31f5a9bb6a1dd35a185a1601af48a887c217c0bde0b2ac0dbc0
|
File details
Details for the file solinkify_gate-0.2.0-py3-none-any.whl.
File metadata
- Download URL: solinkify_gate-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
935b6b4fd91b2b16680bedc8333e8ddb06f5e0669fd013f2e629ab38fba9cf0e
|
|
| MD5 |
74202a680a37cf089e2c4b020c4d858b
|
|
| BLAKE2b-256 |
84a127c15f69446e383a09abd3061dfc8569fd03a07bca511ebe75ce8060e545
|