Open Self‑Negotiating API Protocol
Version: 1.0 • License: Apache 2.0
OpenSNAP is a minimal, machine‑to‑machine HTTP handshake that lets autonomous agents discover API pricing, negotiate bids, and attach payment vouchers—independent of any particular settlement layer. Think of it as the TCP of metered API commerce: a simple “offer‑ack‑pay‑invoke” protocol that any payment rail (blockchain, Interledger, centralized ledger or Stripe) can plug into.
- Protocol‑First
- Agnostic to payment networks: blockchain, Lightning, Interledger STREAM, or centralized tokens.
- Extends OpenAPI with machine‑readable pricing metadata.
- Self‑Negotiating
- Clients fetch
x-price-base
,x-pricing-algo
,x-min-price
,x-max-price
, compute a bid, and send aCALL-OFFER
. - Server responds with
CALL-ACK
(proceed) orCALL-REJECT
(decline).
- Clients fetch
- Voucher‑Based
- Payment proof carried as an HTTP header (
X-OpenSNAP-Voucher
), validated per request. - Settlement layer is pluggable (blockchain channels, ILP STREAM, centralized tokens).
- Payment proof carried as an HTTP header (
- Play‑Money Reference
- Includes an HMAC “voucher” adapter for zero-barrier prototyping.
/
├── examples/server.py # Example FastAPI server implementing OpenSNAP
├── examples/client.py # Example Python client demonstrating the handshake
└── rfc.md # Protocol specification & message schemas
-
Discovery
GET /openapi.json
Returns an OpenAPI spec extended with
x-price-base
,x-pricing-algo
,x-min-price
,x-max-price
. -
Negotiation
- Client → Server (
CALL-OFFER
):X-OpenSNAP-Offer: {"endpoint":"/video/generate","bid":0.002}
- Server → Client:
200 OK
(ACK) or402 Payment Required
(REJECT)
- Client → Server (
-
Payment & Invocation
- Client attaches:
X-OpenSNAP-Voucher: <opaque-blob>
- Server verifies voucher, then processes HTTP body.
- Client attaches:
-
Settlement
- Off‑protocol via any adapter: blockchain, ILP, centralized ledger.
- Protocol Agnostic
- Define only the handshake; payment backends are adapters.
- Encourage community to build Solana, Lightning, ILP, or JWT adapters.
- Reference Implementations
server.py
/client.py
for play‑money prototyping.- Easy to extend: swap
rfc.md
and adapter code.
- Community‑First
- Open RFC (
rfc.md
) on GitHub for issues and PRs. - Target AI/agent ecosystems (LangChain, AutoGPT) with plugins.
- Open RFC (
- Sandbox & SDKs
- Public sandbox for testing without real funds.
- Official client SDK that abstracts voucher plumbing.
- Clone Repo
git clone https://github.com/cashputation/OpenSNAP.git cd protocol
- Run Server
pip install fastapi uvicorn python3 server.py
- Run Client
pip install requests python3 client.py
- RFC:
rfc.md
in this repo - Issues: https://github.com/cashputation/OpenSNAP/protocol/issues
- Discussions: https://github.com/cashputation/OpenSNAP/protocol/discussions
Apache 2.0 © OpenSNAP Contributors