Ask402

Which x402 SDK or library should I use?

Short answer

Use the official SDK for your language where one exists. JavaScript and TypeScript use the @x402 packages on npm, Python uses the x402 package on PyPI, and Go uses the module in the x402 repository. Rust, Ruby, Java and Elixir have community libraries. Older un-scoped npm packages such as x402-express are version 1 and are legacy.

Official SDKs

LanguagePackageCovers
JavaScript, TypeScript@x402/* on npmClients, server middleware, facilitator, many networks
Pythonx402 on PyPIFastAPI and Flask servers, httpx and requests clients
Gogithub.com/x402-foundation/x402/go/v2Client, server and facilitator

All three are developed in the x402 Foundation's repository and released often.

The JavaScript packages, by job

You want toInstall
Pay from fetch@x402/fetch
Pay from Axios@x402/axios
Charge in Express@x402/express
Charge in Next.js@x402/next
Charge in Hono@x402/hono
Charge in Fastify@x402/fastify
Show a payment page to people in a browser@x402/paywall
Use x402 inside MCP@x402/mcp
Add the Bazaar listing and other extensions@x402/extensions

Each also needs @x402/core and one package per network family: @x402/evm for Ethereum-style chains, @x402/svm for Solana, and others for Algorand, Aptos, Stellar and more.

Community libraries

LanguageLibraryNotes
Rustx402-rs (x402-axum, x402-reqwest)Listed in the official third-party SDK page. Includes a self-hostable facilitator
Rubyx402-railsRails paywall helper from Quicknode
JavaMogami x402-java-client and Spring Boot starterThird-party. The x402 repository has a Java module, but we could not confirm a published release
Elixirraxol_paymentsx402 and MPP client with spend limits

There is no official Rust SDK.

Version 1 packages are legacy

Before version 2, the npm packages were un-scoped: x402, x402-express, x402-axios, x402-fetch, x402-hono, x402-next. Tutorials from 2025 use them. For new work use the @x402/* scope, which supports version 2 and can still read version 1. See version 1 and version 2 compared.

Not every SDK supports every feature

The schemes beyond exact are unevenly supported. auth-capture, for example, is only in the TypeScript and Go SDKs. If you need upto or batch-settlement, check the SDK feature table in the official documentation before choosing a language.

Libraries that cover more than x402

Some tools speak x402 and MPP both, which helps if you buy from sellers on either: Faremeter, the Solana Foundation's pay command-line tool, and platform SDKs from Cloudflare and thirdweb.

The SDK directory lists these with links.

Sources

Facts checked against these sources on . Protocols change, so the official specification wins if it disagrees with this page. Read this page as Markdown.

Who writes this. Ask402 is published by Havok Holdings LLC, which also runs Agent402, one of the x402 services covered here. Agent402 is labelled wherever it appears. Everything else is described from each project’s own documentation, and nobody pays to be listed.