Repolode
x402-foundation

x402-foundation/x402

An open internet payments protocol built on HTTP, letting servers charge per request via the 402 Payment Required status.

Open-source alternative to:Stripe

Stars
6,744
Forks
2,209
Open issues
756
Last commit
6 days ago

What is it?

x402 is an open standard for internet-native payments. It lets a resource server, such as an API or webpage, ask a client for payment using the HTTP 402 Payment Required status, and the client responds with a signed payment in a request header. The protocol is designed to work with both crypto and fiat value, across multiple networks and tokens.

In a typical flow, the server returns payment requirements, the client selects one and sends a payment payload, and a facilitator verifies and settles the payment on-chain before the server returns the resource. Payment schemes such as exact, upto and batch-settlement define how money moves, while networks define where it settles. The project provides SDKs in TypeScript, Python and Go, with Express, Fetch, Axios, Hono, Next and other integrations.

The design emphasizes that clients and servers should not need to handle gas or RPC details, which are pushed into the facilitator. Payments are meant to be non-custodial, so facilitators or servers cannot move funds beyond what the client intended.

Key features

  • 01Returns HTTP 402 with payment requirements that clients can act on.
  • 02Supports multiple payment schemes, including exact, upto and batch-settlement.
  • 03Works across blockchain networks and fiat value through pluggable chain implementations.
  • 04Provides SDKs for TypeScript, Python and Go.
  • 05Offers middleware for Express, Fastify, Hono, Next and other frameworks.

Use cases

  • Charging per request for a paid API without user accounts or subscriptions.
  • Selling access to articles, data or files with small per-view payments.
  • Enabling AI agents or automated clients to pay for web resources over HTTP.

Quick start

  1. 1

    Install the TypeScript Express server packages

    npm install @x402/core @x402/evm @x402/svm @x402/express
  2. 2

    Install the Python package

    pip install x402
  3. 3

    Install the Go module

    go get github.com/x402-foundation/x402/go/v2

Things to know

  • Payment schemes and network support vary, so clients and facilitators must explicitly support each (scheme, network) pair.
  • The README advises against assuming the public x402.org facilitator for mainnet EVM production use.

Topics

FAQ

What is x402?
An open internet payments protocol built on HTTP, letting servers charge per request via the 402 Payment Required status. x402 is an open standard for internet-native payments. It lets a resource server, such as an API or webpage, ask a client for payment using the HTTP 402 Payment Required status, and the client responds with a signed payment in a request header. The protocol is designed to work with both crypto and fiat value, across multiple networks and tokens.
Is x402 free to use? What license does it have?
x402 is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is x402 still maintained?
Actively maintained. The last commit to x402 was on Oct 15, 2026.
What can I use x402 for?
Charging per request for a paid API without user accounts or subscriptions. Selling access to articles, data or files with small per-view payments. Enabling AI agents or automated clients to pay for web resources over HTTP.
How do I install x402?
Install the TypeScript Express server packages: npm install @x402/core @x402/evm @x402/svm @x402/express Install the Python package: pip install x402 Install the Go module: go get github.com/x402-foundation/x402/go/v2
Where can I get x402?
The source code and installation instructions are on GitHub: https://github.com/x402-foundation/x402

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects