io.github.Drock91/bitbooth-fetch
Pay-per-fetch via x402. Agent pays 0.005 USDC, gets clean markdown for any URL. No API keys.
Ask AI about io.github.Drock91/bitbooth-fetch
Powered by Claude Β· Grounded in docs
I know everything about io.github.Drock91/bitbooth-fetch. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
BitBooth
Pay-per-call x402 endpoints for AI agents on Base mainnet. Six paid endpoints live, settling through the Coinbase CDP Facilitator, plus an MCP fetch server on npm. No API keys, no signup, no humans in the loop.
npm install @bitbooth/mcp-fetch
Built on the x402 protocol (Coinbase + Linux Foundation). All six paid endpoints have settled real USDC on Base mainnet via the CDP Facilitator.
π° Six paid endpoints live on Base mainnet. Discoverable at
/bazaar.jsonand listed in awesome-x402 (PR pending). All six settle through the Coinbase CDP Facilitator (api.cdp.coinbase.com/platform/v2/x402). No API keys, no signup, no humans in the loop.π‘οΈ Testnet by default for the MCP fetch package. A fresh
@bitbooth/mcp-fetchinstall spends free Base Sepolia USDC, not real money. Opt into mainnet explicitly by settingBITBOOTH_CHAIN_ID=8453.π Self-hosted bazaar discovery. Every paid endpoint is enumerated at
/bazaar.jsonso agents can crawl the catalog directly. Each entry carries the canonical bazaar extension fields (discoverable,category,tags,info,schema).
Six paid endpoints live on Base mainnet
| Path | Price | What it does |
|---|---|---|
POST /v1/cdp/echo | 0.001 USDC | x402 reference implementation. Smallest possible paid endpoint β useful as an integration sanity check. |
POST /v1/cdp/json-repair | 0.001 USDC | Repairs malformed JSON output from LLM tool calls. Optional JSON Schema validation pass. |
POST /v1/cdp/faker | 0.001 USDC | Synthetic test data via @faker-js/faker. Declarative templates, seeded reproducibility, 1β100 records per call. |
POST /v1/cdp/render-pro | 0.05 USDC | Full Playwright JS rendering + Mozilla Readability extraction β markdown. Handles SPAs that naive HTTP fetch cannot. |
POST /v1/cdp/web-diff | 0.05 USDC | Renders a URL fresh and returns a structured diff against a previous markdown snapshot the caller supplies. Built for monitoring agents. |
POST /v1/cdp/approval-safety | 0.05 USDC | Pre-flight risk check for ERC-20 approve(spender, amount). Flags unlimited approvals to fresh contracts, EOA spenders, copycat tokens, known-malicious spenders. |
All six share the same withCdpX402(spec, inner) middleware β single source of truth for verification, settlement, and bazaar shape. Each one returns a canonical x402 v2 challenge to a request that arrives without an X-Payment header.
curl -i -X POST https://app.heinrichstech.com/v1/cdp/echo
# HTTP/1.1 402 Payment Required
# content-type: application/json
#
# {
# "x402Version": 2,
# "error": "X-PAYMENT header is required",
# "resource": {
# "url": "https://app.heinrichstech.com/v1/cdp/echo",
# "description": "BitBooth echo endpoint β pays a tiny USDC fee, returns a JSON echo. Reference implementation of the x402 + CDP Facilitator + Bazaar discovery loop.",
# "mimeType": "application/json"
# },
# "accepts": [{
# "scheme": "exact",
# "network": "eip155:8453",
# "amount": "1000",
# "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
# "payTo": "0xDa2F35d283c42dd60B965322394bc658a5c1769F",
# "maxTimeoutSeconds": 300,
# "extra": { "name": "USD Coin", "version": "2" }
# }],
# "extensions": { "bazaar": { "discoverable": true, "category": "utility", "tags": [...], "info": {...}, "schema": {...} } }
# }
Try it right now
The flagship agent-native endpoint. No API key. No signup. Just pay.
# 1. Hit the endpoint β get a 402 with a payment challenge
curl -X POST https://app.heinrichstech.com/v1/fetch \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com","mode":"fast"}'
# HTTP/1.1 402 Payment Required
# {
# "error": { "code": "PAYMENT_REQUIRED", "message": "Payment required" },
# "challenge": {
# "nonce": "bc98010eb4f84ab6c25b9a34188dcec0",
# "expiresAt": 1778092838,
# "resource": "/v1/fetch",
# "accepts": [{
# "scheme": "exact",
# "network": "eip155:84532",
# "payTo": "0xDa2F35d283c42dd60B965322394bc658a5c1769F",
# "asset": "USDC@0x036CbD53842c5426634e7929541eC2318f3dCF7e",
# "amount": "5000"
# }],
# "amountWei": "5000",
# "assetSymbol": "USDC",
# "chainId": 84532
# }
# }
# 2. Agent signs + sends 0.005 USDC on Base Sepolia to payTo
# 3. Agent retries with X-Payment header containing the tx hash
# 4. Gets 200 OK + clean markdown back
For full Playwright JS rendering on real-money mainnet, use /v1/cdp/render-pro (0.05 USDC on Base mainnet).
Install as an MCP server
One line and any Claude Code / Cursor / Windsurf / Continue agent can use it:
npm install @bitbooth/mcp-fetch # 1.0.2 on npm
Add to your MCP config:
{
"mcpServers": {
"bitbooth-fetch": {
"command": "npx",
"args": ["-y", "@bitbooth/mcp-fetch"],
"env": { "BITBOOTH_AGENT_KEY": "0x<your-testnet-wallet-private-key>" }
}
}
}
See packages/mcp-fetch/README.md for full configuration.
How it works
Agent BitBooth Your API
β β β
βββ POST /v1/cdp/echo βββββββββΊβ β
ββββ 402 Payment Required ββββββ (challenge: amount, nonce) β
β β β
βββ send USDC on-chain βββββββββββββββββββββββββββββββββββββΊ β
βββ retry with X-Payment ββββββΊβ β
β βββ verify via CDP Facilitator βΊβ
β ββββ confirmed βββββββββββββ β
β βββ execute handler βββββββββΊ β
ββββ 200 OK βββββββββββββββββββββββββββββββββββββββββββββββββββ
- Agent calls a paywalled endpoint
- Server returns
402 Payment Requiredwith a signed challenge (amount, nonce, payTo, expiry) - Agent signs and sends the payment from its wallet
- Agent retries with the tx hash (or signed authorization) in the
X-Paymentheader - BitBooth verifies on-chain via the configured facilitator (CDP for the
/v1/cdp/*suite, native verifier for everything else), checks replay protection, executes the handler - Server responds
200 OK
One round-trip. Verified end-to-end on Base Mainnet via the Coinbase CDP Facilitator today.
Networks
| Network | Asset | Used by | Status |
|---|---|---|---|
Base Mainnet (eip155:8453) | USDC | All six /v1/cdp/* paid endpoints | β Live β settling via Coinbase CDP Facilitator. 12+ confirmed real-money settlements. |
Base Sepolia (eip155:84532) | USDC | /v1/fetch testnet path + @bitbooth/mcp-fetch default | β End-to-end verified, free testnet USDC, development only |
Adapter code for additional rails (XRPL, BSC, Solana, Stellar) lives in src/adapters/ for future expansion but is not currently advertised in the live accepts[] array. The current focus is the six Base mainnet endpoints.
API
| Method | Path | Auth | Description |
|---|---|---|---|
POST | /v1/cdp/echo | x402 (CDP) | Reference paid endpoint. 0.001 USDC on Base mainnet. |
POST | /v1/cdp/json-repair | x402 (CDP) | Repair LLM tool-call JSON. Optional schema validation. 0.001 USDC. |
POST | /v1/cdp/faker | x402 (CDP) | Synthetic data via @faker-js/faker. 0.001 USDC. |
POST | /v1/cdp/render-pro | x402 (CDP) | Playwright JS rendering + Readability extraction. 0.05 USDC. |
POST | /v1/cdp/web-diff | x402 (CDP) | Render fresh + diff vs caller-supplied previous markdown. 0.05 USDC. |
POST | /v1/cdp/approval-safety | x402 (CDP) | ERC-20 approve() pre-flight risk assessment. 0.05 USDC. |
GET | /bazaar.json | β | Self-hosted catalog of all paid endpoints (canonical bazaar shape). |
POST | /v1/fetch | x402 only | URL β clean markdown. Modes: fast / full. No API key. Pay-per-call on Base Sepolia testnet. |
POST | /v1/resource | API key + x402 | Paywalled resource (tenant-configured pricing) |
POST | /v1/resource/premium | API key + x402 | Premium resource (2Γ price) |
POST | /v1/resource/bulk | API key + x402 | Bulk operations (amount Γ item count) |
GET | /v1/payments | API key | Payment history (cursor pagination) |
GET | /v1/health | β | Health check |
GET | /v1/health/ready | β | Readiness (DDB + RPC + secrets) |
Full spec in openapi.yaml.
Architecture
bitbooth-gateway/
βββ src/
β βββ routes/ # HTTP route tables
β βββ controllers/
β β βββ cdp-echo.controller.js
β β βββ cdp-json-repair.controller.js
β β βββ cdp-faker.controller.js
β β βββ cdp-render-pro.controller.js
β β βββ cdp-web-diff.controller.js
β β βββ cdp-approval-safety.controller.js
β β βββ bazaar.controller.js # serves /bazaar.json catalog
β β βββ (fetch, payments, portal, admin, ...)
β βββ services/ # Business logic, orchestration
β βββ adapters/
β β βββ base/ # Base mainnet + Sepolia (viem)
β β βββ bsc/ # BSC mainnet + testnet (viem)
β β βββ xrpl/ # Native XRPL (xrpl.js)
β β βββ xrpl-evm/ # XRPL EVM Sidechain (ethers)
β β βββ solana/ # Solana mainnet + devnet (@solana/web3.js)
β β βββ stellar/ # Stellar pubnet + testnet (stellar-sdk)
β β βββ ows/ # Open Wallet Standard
β βββ middleware/
β β βββ x402.middleware.js # native verifier (XRPL, BSC, Solana, Stellar)
β β βββ cdp-x402.middleware.js # CDP Facilitator wrapper for /v1/cdp/*
β β βββ (auth, rate-limit, idempotency, errors, CORS)
β βββ validators/ # Zod schemas (every boundary validated)
β βββ repositories/ # DynamoDB (10 tables)
β βββ handlers/ # Lambda entry points (api / fetch / proxy / webhook / dlq-sweep)
β βββ lib/ # Config, logger, errors, crypto, metrics, secrets
βββ infra/ # AWS CDK (Lambda + API GW + DDB + Secrets Manager + WAF)
βββ packages/
β βββ mcp-fetch/ # @bitbooth/mcp-fetch β MCP server for fetch tool
β βββ langchain-bitbooth/ # LangChain tool wrapper
β βββ bitbooth-py/ # Python client
βββ tests/ # 3,400+ unit tests + integration tests
βββ scripts/ # Smoke tests, load tests, ops tools
βββ docs/ # Deploy guide, integration guide, ADRs
Stack
- Runtime: Node 20, pure JavaScript (ESM), no TypeScript
- Cloud: AWS Lambda, API Gateway, DynamoDB, Secrets Manager, CloudWatch
- Network: Base Mainnet for all paid endpoints (
/v1/cdp/*); Base Sepolia for the MCP fetch testnet path - Facilitator: Coinbase CDP for every paid endpoint (
api.cdp.coinbase.com/platform/v2/x402) - Protocol: x402 V2 (HTTP 402 Payment Required) + bazaar discovery extension
- Validation: Zod at every boundary
- Testing: Vitest β 3,400+ tests, all passing
- Infra: AWS CDK (stage-aware: dev/staging/prod)
- Deploy: esbuild bundles per-Lambda,
cdk deploy
What's built
- Six paid endpoints on Base mainnet (
/v1/cdp/*) β echo, json-repair, faker, render-pro, web-diff, approval-safety. All settle through the Coinbase CDP Facilitator. Discoverable at/bazaar.jsonand listed in awesome-x402 (PR pending merge). - x402 V2 protocol β challenge/response with nonce-based replay protection, on-chain settlement via the CDP Facilitator. Verified end-to-end on Base Mainnet today.
- Self-hosted bazaar discovery at
/bazaar.jsonβ canonical resource catalog withdiscoverable,category,tags,info,schemafields per resource so agents can enumerate the surface programmatically. - MCP server β
@bitbooth/mcp-fetchv1.0.2 on npm. One-line install for any Claude Code / Cursor / Windsurf / Continue agent. - Agent-native fetch endpoint (
/v1/fetch) β zero signup, zero API key, pure pay-per-call. Two modes:fast(0.005 USDC, raw HTML β markdown) andfull(0.005 USDC, article extraction via Readability + Turndown). For full Playwright JS rendering on mainnet, use the dedicated/v1/cdp/render-proendpoint above. - Multi-tenant SaaS β self-service signup, API keys, per-route pricing, session-based client portal.
- Fraud prevention β velocity rules, nonce tracking, amount bounds, configurable thresholds.
- Rate limiting β token bucket, 4 tiers (Free/Starter/Growth/Scale), per-IP for anonymous callers.
- Idempotency β 24h result caching via DynamoDB TTL.
- Admin console β branded admin at
app.heinrichstech.com/adminwith Tenants, Metrics, Earnings (Grafana-style), self-service password rotation. - Webhook DLQ β retry with exponential backoff, max-age cleanup.
- Observability β CloudWatch alarms, structured pino logging with redaction.
- OpenAPI 3.0 spec at
/openapi.yaml, auto-validated against live routes in CI.
Quick start
npm install # install deps
npm run lint # eslint --max-warnings=0
npm test # 3,400+ tests, ~20s
npm run build # esbuild bundles to dist/
npm run cdk:synth # validates CDK stack (STAGE=dev)
Deploy
# Staging (Base Sepolia, free testnet USDC)
STAGE=staging npm run cdk:deploy:staging
# Production (Base mainnet, real USDC + CDP Facilitator)
STAGE=prod npm run cdk:deploy:prod
Full walkthrough in docs/DEPLOY.md.
Testing
npm test # run all 3,400+ unit tests
npm run test:integration # requires LocalStack + testnet RPC
npm run test:coverage # coverage report (target β₯80% on services/ and middleware/)
npm run smoke:cdp # 29-assertion negative-path smoke against the live deployment
Docs
CLAUDE.mdβ development conventions and non-negotiables (read before contributing)openapi.yamlβ full API specificationdocs/DEPLOY.mdβ CDK deployment guidedocs/RUNBOOK.mdβ operational runbook (alerts, incident response)docs/integration-guide.mdβ 5-minute API integration walkthroughdocs/BAZAAR_RESOURCES.mdβ paid-endpoint catalog (mirror of/bazaar.json)docs/adr/β architecture decision recordspackages/mcp-fetch/README.mdβ MCP server for AI agents
Security
- No secrets in code β all loaded from AWS Secrets Manager at cold start
- Least-privilege IAM per Lambda
- x402 endpoints verify the on-chain transaction (or signed EIP-3009 authorization for the CDP suite), check nonce against DDB for replay protection, enforce a β€ 120s payment window
- Webhooks verify HMAC before any business logic
- Logger redacts API keys, private keys, signed payloads
- Input size limits: JSON body β€ 100KB unless explicitly opted in
- Rate limits via API Gateway usage plans + per-account token bucket
See CLAUDE.md for the full security posture.
Contributing
This is a working open-source x402 reference gateway. PRs welcome. Before opening one:
npm run lintmust pass with zero warningsnpm testmust pass all 3,400+ testsnpm audit --audit-level=highmust return 0- Add Zod validators for any new request shape
- No TypeScript β this is pure JavaScript + JSDoc typedefs (see
CLAUDE.md)
License
MIT β free for commercial and personal use.
Links
