Integrate in one minute.
Gatefare is an x402 payment proxy for APIs. AI agents pay USDC per request; publishers get 90% split on-chain. Two tracks — one if you're an agent (buying), one if you're a developer (selling or integrating). Complete endpoint reference at the bottom.
Four facts everyone hits on their first call. Read once, then copy any snippet below without guessing.
- Base URL
https://gatefare.io. All paths in this doc are relative to it. Self-hosted deployments swap the origin — the paths and shapes are identical.- CSRF header (required)
- Every non-GET request must carry
X-Gatefare-Request: 1(any non-empty value works). Without it the server replies403 · CSRF_HEADER_REQUIRED. This is a simple anti-CSRF gate: browsers can't forge custom headers cross-origin. All curl / fetch / httpx examples on this page already include it. - Auth header
- Pass a JWT or a PAT in
Authorization: Bearer <token>. PATs are recommended for scripts (prefixgfpat_, never expire by default). Details in step II / III. - Rate limits
- 120/min per IP on catalog reads · 60/min per IP on the payment proxy · 20/15min per IP on auth endpoints. Responses on the 429 path carry standard
RateLimit-*headers so clients can back off automatically. - Network
- Production is Base mainnet (
eip155:8453). Test environment is Base Sepolia (eip155:84532) — free USDC from Circle faucet. Testnet APIs are hidden from the public catalog by default; pass?includeTestnet=1to see them. - Errors
- Every error response is JSON:
{ "error": "message", "code": "MACHINE_CODE" }. Stable machine codes at the bottom of this page — switch on them, not the message string.
Sign in with your wallet (SIWE)
Gatefare uses EIP-4361 Sign-In With Ethereum. Your agent signs one message; that signature doubles as Terms acceptance and authentication. No email, no password.
# pip install requests eth-account
import requests
from eth_account import Account
from eth_account.messages import encode_defunct
WALLET_KEY = "0xYOUR_PRIVATE_KEY" # Your Base wallet
BASE_URL = "https://gatefare.io"
H = {"Content-Type": "application/json", "X-Gatefare-Request": "1"}
account = Account.from_key(WALLET_KEY)
# 1. Ask for a nonce.
r = requests.post(f"{BASE_URL}/api/auth/siwe/nonce", headers=H, json={
"wallet": account.address,
"chainId": 8453, # Base mainnet
})
r.raise_for_status()
chal = r.json()
print(f"ToS version you're accepting by signing: {chal['tosVersion']}")
# 2. Sign the exact message (includes ToS acceptance).
msg = encode_defunct(text=chal["message"])
signed = Account.sign_message(msg, private_key=WALLET_KEY)
# 3. Verify → receive JWT + user.
r = requests.post(f"{BASE_URL}/api/auth/siwe/verify", headers=H, json={
"wallet": account.address,
"signature": signed.signature.hex(),
})
r.raise_for_status()
session = r.json()
print(f"Logged in as user {session['user']['id']}, JWT: {session['token'][:20]}…")Mint a long-lived access token (PAT)
The JWT from step 1 expires in 7 days. For long-running agents, exchange it immediately for a personal access token (gfpat_…). Store it securely — if it leaks, revoke from the dashboard.
curl -X POST https://gatefare.io/api/auth/pat \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-H "X-Gatefare-Request: 1" \
-d '{"label":"agent-prod","scopes":["read"],"expiresInDays":365}'
# → { "token": "gfpat_abc123…", "summary": { "id": 1, "label": "agent-prod", ... } }
#
# Save the "token" string in a secret manager. You can't retrieve it again.
# Use it exactly like a JWT:
curl https://gatefare.io/api/auth/me \
-H "Authorization: Bearer gfpat_abc123…"Tokens carry the gfpat_ prefix so scanners like gitleaks flag leaks in public repos instantly. Choose scopes carefully — see the PAT scopes table.
Discover APIs in the marketplace
Browse every public API with a single HTTP GET. Filter by category, price, or full-text search. No auth required for catalog reads.
# Browse by category + price
curl "https://gatefare.io/api/catalog?category=ai-ml&price_max=0.05&sort=popular"
# Full-text search
curl "https://gatefare.io/api/catalog?q=weather&sort=popular"
# Autocomplete suggestions (up to 8)
curl "https://gatefare.io/api/catalog/search/suggest?q=weath"
# Trending this week (system-curated collection)
curl "https://gatefare.io/api/catalog/collections/system:trending"
# Category list with API counts
curl "https://gatefare.io/api/catalog/categories"See the public marketplace and llms.txt (LLM-friendly site map) for structured discovery.
Pay per request with x402
Call the proxy URL. First call returns 402 Payment Required with the full x402 v2 payload. Second call, with an X-Payment header (base64-encoded signed USDC transfer), returns the upstream response. x402 clients handle this handshake automatically.
# pip install x402-client requests
from x402.client import PaymentClient
client = PaymentClient(wallet_private_key="0xYOUR_KEY", chain_id=8453)
response = client.get("https://gatefare.io/p/alice/weather")
# First call returns 402; client auto-signs USDC transfer + retries.
# Returns the upstream response body.
print(response.json())The proxy caps every payment at 1.1× the posted price server-side; larger X-Payment amounts are rejected. This protects agents from a malicious publisher raising the price between discovery and sign.
Budget limits — don't overspend
Every x402-aware client should also enforce its own budget:
- Per-call cap: reject any API whose
priceexceeds your max. - Per-task budget: sum costs across all calls, abort when you hit the limit.
- Balance check: read your wallet USDC balance before each call if you're on a tight budget.
- Retry with ceiling: if you see
402after a successful signing round, the price probably changed — refresh the quote, don't silently re-sign.
Coinbase AgentKit works out of the box
AgentKit ships with an x402 helper. Point it at https://gatefare.io/p/…, supply the signer, done.
Token scopes.
Scopes are monotonic — each one implies everything weaker. Pick the narrowest one your use case needs; you can always mint a second token if you need more.
Stable error codes.
All error responses are JSON with a human error string and a stable machine code. Switch on code; the string may be tuned for clarity.
Complete endpoint reference.
Every route exposed by the platform. Scopes marked apply to PATs; JWT sessions satisfy any scope.