Ledger Gate

Introduction

Welcome to the Ledger Gate documentation. Learn how to track and analyze your x402-monetized APIs in minutes.

What is Ledger Gate?

Ledger Gate is a developer-first observability platform for x402-monetized HTTP APIs. Drop the @ledgergate/ledgergate-sdk middleware into your Express or Fastify server and instantly gain real-time visibility into payment flows, request latency, and endpoint activity — without ever handling funds or private keys.

Why Ledger Gate?

The x402 Payment Required protocol makes it trivially easy to gate API access behind micropayments, but it gives you no built-in observability. You can't see which endpoints are being hit, which payments succeed or fail, or what your revenue looks like over time.

Ledger Gate fills that gap.

Key Features

  • x402-Native — First-class detection of HTTP 402 responses, payment addresses, networks, tokens, and verification status.
  • Passive Middleware — Zero changes to your business logic. The SDK hooks into request/response lifecycle events automatically.
  • Fail-Open Design — Every SDK operation is wrapped in try-catch. An analytics failure will never take down your API.
  • Privacy by Default — No request or response bodies are captured. Sensitive headers are automatically redacted. IP addresses are SHA-256 hashed.
  • Non-Custodial — The SDK is purely observational. It stores metadata, never funds or keys.
  • Free Tier — Start tracking today, no credit card required.

How It Works

Incoming Request

@ledgergate/ledgergate-sdk Middleware
      ↓                      ← emits request.received event
Your Route Handler

Response Hook
      ↓                      ← emits payment.required / payment.verified / request.completed
Async Event Queue

Ledger Gate Analytics API    ← batched, retried, non-blocking

Each request runs through the SDK middleware invisibly. The SDK creates a unique request context, checks the sampling rate, and on response inspects the status code and headers for x402 payment signals. Events are buffered in-memory and flushed in batches — the hot path of your application is never blocked.

Supported Frameworks

FrameworkInstall
Express 4/5npm install @ledgergate/ledgergate-sdk
Fastify 5npm install @ledgergate/ledgergate-sdk

More adapters (Hono, Koa, plain node:http) are planned.

Quick Start

Ready to integrate? Head to the Getting Started guide to add the SDK in under 5 minutes.

On this page