DEV Community

carrierone
carrierone

Posted on

I Built a Pay-Per-Query Data Marketplace with x402 Crypto Micropayments

I Built a Pay-Per-Query Data Marketplace with x402 Crypto Micropayments

What if buying data worked like buying a coffee? Walk up, pay, get what you ordered. No membership card, no monthly subscription, no waiting for account approval.

That's what I built with Verilex Data — a self-hosted data sales platform where every query costs a fraction of a cent in USDC, paid instantly via the x402 protocol.

The Problem

I kept running into the same pattern: I need data from an API. The API costs $49/month minimum. I only need 50 queries. I'm paying $1/query for a service designed for $0.01/query at scale.

Every data provider forces you into subscriptions. Even government data that's already public domain gets locked behind $49-299/month plans.

The x402 Solution

x402 is an open protocol by Coinbase that revives the HTTP 402 status code. Here's how it works:

  1. Client sends GET /api/v1/npi?state=TX
  2. Server responds 402 Payment Required with price + wallet address
  3. Client signs a USDC transfer (EIP-712 on Base chain)
  4. Client resends request with the signed payment in a header
  5. Server verifies, settles on-chain, returns data

One HTTP round-trip. No API keys. No accounts. No subscriptions.

What I Built

20 datasets across three categories:

Government & Business — NPI healthcare providers (9M records), SEC EDGAR filings, PACER court records, 1.6M US patents, government contracts, weather data, OTC company shell risk scoring, economic indicators from FRED.

Crypto Intelligence — OFAC sanctions screening ($0.005/query — Chainalysis charges $50K/year), whale wallet tracking, address labels with risk scores, token holder concentration, DEX trade history, DeFi liquidation signals.

Prediction Markets — Polymarket smart money tracker, AI-powered cross-platform arbitrage (uses Ollama embeddings to match same-event markets across Polymarket and Kalshi), resolution source intelligence, order book microstructure.

The Tech Stack

Everything runs on one Debian 13 VM on my Proxmox cluster:

  • API: Express + TypeScript with self-hosted x402 facilitator
  • Database: PostgreSQL 16 + TimescaleDB
  • Analytics: DuckDB querying Parquet files on MinIO
  • Pipeline: Python collectors on APScheduler (15-min to weekly intervals)
  • Site: Astro + Tailwind (static, served by nginx)
  • AI: Ollama (nomic-embed-text) for semantic matching
  • Monitoring: Umami analytics, uptime cron, data freshness tracking

Total vendor cost: $0. Everything is FOSS and self-hosted.

Data Freshness Headers

Every paid response includes:

X-Data-Stale: false
X-Data-Last-Updated: 2026-03-17T05:03:08.108Z
X-Data-Age-Seconds: 6235
Enter fullscreen mode Exit fullscreen mode

Your code can check X-Data-Stale and stop querying if data hasn't been refreshed. You still get charged (prevents abuse), but you're warned.

Change Feeds

Every high-frequency dataset supports ?since= for efficient polling:

GET /api/v1/sanctions/changes?since=2026-03-16T00:00:00Z
Enter fullscreen mode Exit fullscreen mode

Returns only records updated since the timestamp, with next_since for chaining. Empty responses are fast and cheap.

AI Agent Integration

The platform is built for AI agents:

  • MCP server with 50+ tools (Smithery)
  • Streamable HTTP endpoint at https://api.verilexdata.com/mcp
  • llms.txt for AI crawler discovery
  • OpenAPI 3.1 with Scalar interactive docs
  • Schema.org JSON-LD on every page

Self-Hosting the x402 Facilitator

The biggest challenge was the x402 facilitator. Coinbase's public facilitator (facilitator.x402.org) only supports testnet chains. For mainnet payments, I had to self-host using @x402/core's x402Facilitator class with a viem wallet signer, exposed as a local HTTP server that the HTTPFacilitatorClient connects to.

Try It

Free endpoints (no payment needed):

Website: verilexdata.com
MCP: github.com/carrierone/verilexdata-mcp

Top comments (0)