Make every API call pay its fare.
Loopfare is an x402 v2 reverse proxy for Base. Sellers put a payment gate in front of an existing HTTP API; AI agents and other buyers pay per request in USDC without buyer accounts, subscriptions, or API keys.
The same service includes:
| Surface | Role |
|---|---|
| Marketing site | Product overview, protocol flow, quickstart, and live health |
| Seller API | Accounts, projects, protected routes, payments, and earnings |
| Paid proxy | Dynamic x402 gates in front of seller origins |
| CLI | Seller administration and budget-aware buyer payments |
| Agent skill | Machine-readable instructions at /skill.md |
| Documentation center | Hosted guides, manuals, API/CLI references, and raw Markdown at /docs |
AI agent / x402 client
│
│ 1. normal HTTP request
▼
Loopfare paid proxy ── 2. HTTP 402 + PAYMENT-REQUIRED
▲
│ 3. PAYMENT-SIGNATURE
│
├── facilitator verifies and settles USDC on Base
│
└── 4. paid request ──► seller origin API
- Protocol: x402 v2
- Default network: Base Sepolia (
eip155:84532) - Default test facilitator:
https://x402.org/facilitator - Storage: SQLite in WAL mode on a persistent Railway volume
- Runtime: Node.js 22+ and Hono
The public beta defaults to the hosted Base Sepolia service. A first diagnostic and wallet test does not require an account, faucet assets, or blockchain payment:
npx --yes @loopfare/cli@latest doctorFor repeated use, install the command globally:
npm install --global @loopfare/cli@latest
loopfare wallet create
loopfare configNode.js 22 or newer is required. The same npm command upgrades an existing installation. If a global install reports EACCES, do not use sudo; use a Node version manager or the user-owned npm prefix described in the troubleshooting guide. wallet create stores the private key locally without printing it. Back up ~/.loopfare/config.json securely before funding the address.
After funding a disposable wallet with Base Sepolia USDC, the hosted $0.001 demo provides a real x402 test:
loopfare budget set --daily 1
loopfare call https://api-production-dd0a0.up.railway.app/demo/v1/fortuneTo exercise the complete payment workflow without blockchain assets, continue with the local quickstart below. It uses an isolated development-payment header that production refuses to accept.
git clone https://github.com/Rileyh-git/loopfare.git
cd loopfare
cp .env.example .env
npm ci
npm run devThe website and API start at http://localhost:4021.
Run the CLI from this checkout in another terminal. The link step is for local CLI development; ordinary users should install the published package as shown above.
# Optional: make `loopfare` available globally while developing
npm run build -w @loopfare/cli
npm link -w @loopfare/cli
loopfare set-api http://localhost:4021
loopfare doctor
loopfare signup --email you@example.com --json
loopfare projects create \
--name "Weather API" \
--slug weather \
--pay-to 0x0000000000000000000000000000000000000001 \
--json
loopfare protect \
--project PROJECT_ID \
--origin https://httpbin.org \
--path "/*" \
--price '$0.001' \
--jsonUse local dev payment mode without crypto:
loopfare wallet create --json
loopfare budget set --daily 5 --json
loopfare call http://localhost:4021/p/weather/get --dev --jsonThe 0x000…0001 receiving address is a local-development placeholder; never send assets to it. Use an address you control for testnet payments. ALLOW_PRIVATE_ORIGINS=true is intended only for local development. It lets a project proxy a local test server.
All commands accept the top-level --json flag for machine-readable output.
| Command | Description |
|---|---|
loopfare doctor |
Check runtime, hosted service, wallet, budget, and configuration readiness |
loopfare config |
Show redacted local configuration |
loopfare set-api <url> |
Select a hosted, local, or self-hosted Loopfare service |
loopfare signup --email … |
Create a seller account and store the one-time API key |
loopfare login --api-key … |
Store an existing seller API key |
loopfare whoami |
Validate the active seller identity |
loopfare rotate-key |
Replace the active seller API key |
loopfare projects create/list/get/delete |
Manage seller projects |
loopfare protect |
Add a paid route in front of an origin |
loopfare routes list/update/delete |
Operate protected routes |
loopfare earnings --project … |
Inspect payments and earnings |
loopfare wallet create/import/show |
Manage the local buyer wallet |
loopfare budget set/show |
Configure the token-protected daily limit |
loopfare call <url> |
Pay an x402 endpoint and return its response |
Real payments require a configured daily budget by default. --no-budget is an explicit escape hatch. The CLI currently pays only official USDC on Base or Base Sepolia and records settled spend locally as well as on compatible Loopfare proxies.
Buyer private keys are stored in ~/.loopfare/config.json. The directory is mode 0700 and the file is mode 0600. wallet create does not print the private key unless --show-private-key is explicitly supplied.
Public endpoints:
GET /— marketing websiteGET /api— service and endpoint metadataGET /docs,/docs/:page,/docs/:page.md— public documentationGET /health,/health/live,/health/ready— health checksGET /skill.md— agent instructionsPOST /v1/auth/signup— seller signupGET /v1/admin/metrics?days=30— owner-only usage, funnel, route, and revenue metricsPOST|GET /v1/buyer/budget— token-protected buyer budgetGET /demo/v1/fortune— x402 demoANY /p/:projectSlug/*— paid reverse proxy
Seller endpoints require Authorization: Bearer lf_…:
GET /v1/auth/mePOST /v1/auth/rotate-keyGET|POST /v1/projectsGET|DELETE /v1/projects/:idGET|POST /v1/projects/:id/routesPATCH|DELETE /v1/projects/:id/routes/:routeIdGET /v1/projects/:id/paymentsGET /v1/payments
- Seller API keys are shown once and stored as SHA-256 hashes.
- Arbitrary seller origins are checked at configuration time and immediately before every proxy request. Private, loopback, link-local, metadata, multicast, and reserved destinations are blocked in production.
- Redirects from seller origins are not followed.
- Authorization, cookies, payment signatures, budget tokens, hop-by-hop headers, and internal Loopfare headers are not forwarded to seller origins; origin cookies are not returned to buyers.
- Proxy request and response sizes are capped, upstream calls time out, security headers are applied, CORS is allowlisted, and management/proxy rate limits are enabled.
- Real payments settle only after the seller origin succeeds. Successful settlement headers and transaction hashes are preserved and recorded.
- Payment history is scoped to the authenticated seller account.
- Buyer budgets use a separate secret token. They are a compatible-client safety rail, not a wallet-level policy.
- Production refuses to boot with dev payments enabled.
See SECURITY.md for reporting and incident response.
The hosted documentation center is available at /docs. Every guide also has a raw Markdown form at /docs/<slug>.md for agents, search indexing, and offline use.
| Start here | Product use | Build and operate |
|---|---|---|
| Quickstart | Seller manual | API reference |
| Core concepts | Buyer manual | Architecture |
| FAQ | CLI reference | Self-hosting |
| Glossary | Troubleshooting | Operations |
| Agent integration | Error reference | Security model |
The production checklist and contributor guide complete the public manual set.
npm run check
npm audit --omit=devnpm run check runs strict TypeScript checks, production builds, API integration tests, clean-home CLI smoke tests, documentation link validation, and an npm package dry run.
The repository includes railway.toml, nixpacks.toml, and a production runbook at docs/PRODUCTION.md.
Required Railway resources:
- A service rooted at the repository root.
- A volume mounted at
/data. - A generated or custom HTTPS domain.
- These initial variables:
NODE_ENV=production
LOOPFARE_DEV_MODE=false
ALLOW_PRIVATE_ORIGINS=false
SIGNUP_ENABLED=true
LOOPFARE_NETWORK=base-sepolia
FACILITATOR_URL=https://x402.org/facilitator
DATABASE_PATH=/data/loopfare.dbSet DEMO_PAY_TO to an operator-controlled Base address before enabling the paid demo. Railway supplies PORT and RAILWAY_PUBLIC_DOMAIN; the service derives its public URL automatically when PUBLIC_URL is unset.
Keep the public beta on Base Sepolia until the mainnet gate in the production runbook is complete.
loopfare/
├── packages/api/ Hono API, website, paid proxy, SQLite
├── packages/cli/ Seller and buyer CLI
├── docs/ Public guides, references, and operator manuals
├── SECURITY.md
├── railway.toml
└── nixpacks.toml