Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Building a One-Cent API with x402 on Base

Description and use

A one‑cent API was built using x402 on Base, offering free indexes and paid research briefs without accounts or checkout pages. The flow includes payment negotiation, MetaMask signing, mobile deep‑link support, pseudonymous analytics, and comprehensive documentation.

Problem

How to sell a single useful API response for $0.01 without requiring accounts, keys, or checkout pages while keeping the experience frictionless and privacy‑preserving.

Outcome

The one‑cent API loop works end‑to‑end: discovery, free response, payment authorization, settlement, paid response, and privacy‑preserving analytics. Mobile support and clear error messages improved usability.

Workflow

  • 1. Client requests paid route via fetch wrapped with @x402/fetch and @x402/evm. 2. Server responds with 402 and payment requirements. 3. Client signs payment authorization in MetaMask. 4. Request retried with payment payload. 5. Facilitator verifies and settles payment. 6. Server returns paid response with source links. 7. Client displays free or paid content based on response.
  • 8. Mobile visitors without injected wallet trigger MetaMask deep link. 9. Browser generates rotating HMAC pseudonym in X-Launch-Visitor header. 10. Server aggregates unique free/paid users and repeat paid users over 7 days.
  • 11. Public stats endpoint exposes aggregate counts without sensitive data.

Evidence

The live project has three free indexes: GLP-1 questions, supplement interactions, and peptide/longevity questions. Each has a paid counterpart that returns a longer research brief with named source links.

Source

The first stats endpoint counted requests per route and paid unlocks. It intentionally stored no health queries, wallet addresses, IP addresses, or user agents.

Source

The mobile flow now uses a MetaMask app deep link when a provider is missing.

Source

  • Record date: 2026-09-22T03:00:38.809Z