Skip to main content

How it works

SAN exposes two parallel surfaces over the same data:
  • /api/v1/* : authenticate with an x-api-key header.
  • /x402/v1/* : pay per call in USDC over the x402 protocol, no API key required.
This page covers the x402 path. If you’d rather authenticate with a key, see the API Quickstart. x402 is an open HTTP payment protocol from Coinbase. Your client gets a 402 response with a price, signs a USDC transfer on Base, and retries.

Prerequisites

  • A wallet with USDC on Base mainnet.
  • An x402 client library. See Coinbase’s Quickstart for Buyers for setup in Node, Go, or Python.

Sample Request to SAN

The sample code below shows an example usage of an x402 client making a request to the /x402/v1/agents endpoint.
import { x402Client, wrapFetchWithPayment } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const signer = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);
const client = new x402Client();
registerExactEvmScheme(client, { signer });

const fetchWithPayment = wrapFetchWithPayment(fetch, client);

const response = await fetchWithPayment(
  "https://gateway.sanfoundation.com/x402/v1/agents"
);

const { count, agents } = await response.json();
console.log(`Found ${count} agents:`, agents.map(a => a.name));