Skip to main content

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/solinkify discovery 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 with x-solinkify-payer + x-solinkify-prepaid headers (the backend debits its on-chain balance, fail-closed) or x-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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solinkify_gate-0.2.1.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

solinkify_gate-0.2.1-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file solinkify_gate-0.2.1.tar.gz.

File metadata

  • Download URL: solinkify_gate-0.2.1.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for solinkify_gate-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0c57b44fdd392fe7214cdf9d72372fb72b373e0e67d37cbf733d4f74148a92fc
MD5 82570c48f3a14bb7af61db5db326e4a7
BLAKE2b-256 6af9dcf8b24e312783eebf8e62eaca608baddc596ae01785f77a16ba94ad5677

See more details on using hashes here.

File details

Details for the file solinkify_gate-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: solinkify_gate-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for solinkify_gate-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 115aed8150ded67d2e74fe20ec6e63971b3f6d0d75dfefdc51f69af26d034ae8
MD5 1ee8cd5e7342c7411014a35d92f41283
BLAKE2b-256 12f357a5404ef6865a21cf84b2a5f7be2db0fe6cbf145fb7e1da70a248a0cbe0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page