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.3.0.tar.gz (15.3 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.3.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: solinkify_gate-0.3.0.tar.gz
  • Upload date:
  • Size: 15.3 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.3.0.tar.gz
Algorithm Hash digest
SHA256 d300f1709ec3f90c6aa7a0f9b84056306e8d564cf90fac822a18a025c2b82ef2
MD5 39886de7a0b208b711885a86678c2565
BLAKE2b-256 c4cfbef81fe30ae023d7987b5d1b3478c1282aa6f8956ce1caa68b81ce74212d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: solinkify_gate-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.1 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d8aa711d67d53d5fde31d6e8fcb90a325c6e59147bf769f8044f415e4b81f46
MD5 516ecf8e1be785876cae44edb237eb01
BLAKE2b-256 da560d2e2d928b92406db31c994b38eb08418355ade1b5278b622886b4462daf

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