Skip to content

Client / Buyer Integration

As an x402 client (buyer), your application makes requests to resource servers that require payment. When a server responds with HTTP 402 Payment Required, the x402 client libraries automatically handle the payment flow for you -- constructing the appropriate payment payload, submitting it to the facilitator, and retrying the original request with a valid payment header.

How It Works

  1. Your application makes a request to a paid endpoint.
  2. The server responds with 402 Payment Required, including payment requirements in the response headers (price, accepted currencies, facilitator URL).
  3. The x402 client library intercepts the 402 response, constructs a payment payload, and sends it to the facilitator at https://facilitator.svmacc.tech for verification and settlement.
  4. The library retries the original request with the X-Payment header attached.
  5. The server validates the payment and returns the requested resource.

This entire flow is transparent to your application code. You simply use the wrapped HTTP client as you normally would.

Supported Libraries

x402 provides client wrappers for popular HTTP libraries across multiple languages.

TypeScript / JavaScript

LibraryPackageDescription
Fetchx402-fetchWraps the native fetch API with automatic payment handling.
Axiosx402-axiosAdds a payment interceptor to Axios instances.

Python

LibraryPackageDescription
httpxx402Async HTTP client built on httpx with automatic payment handling.
requestsx402Session wrapper for the requests library with automatic payment handling.

Prerequisites

Before integrating an x402 client, you will need:

  • A funded wallet -- An Ethereum-compatible private key with sufficient balance to cover payments on the required network.
  • The resource server URL -- The base URL of the server hosting the paid endpoint.
  • The endpoint path -- The specific path of the resource you want to access.

Environment Variables

All client examples use the following environment variables:

VariableDescription
RESOURCE_SERVER_URLBase URL of the resource server (e.g., https://api.example.com).
ENDPOINT_PATHPath to the paid endpoint (e.g., /api/premium/data).
PRIVATE_KEYYour Ethereum-compatible private key (e.g., 0xabc123...).

Next Steps

Choose the client library that matches your stack and follow the integration guide:

Powered by SVM Facilitator