> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vaults.fyi/llms.txt
> Use this file to discover all available pages before exploring further.

# Keyless API Access with x402 Pay-Per-Request

> Use the x402 protocol to access the Vaults.fyi API without an API key — pay per request in USDC on Base from your agent's onchain wallet.

The Vaults.fyi API supports the [x402 payment protocol](https://www.x402.org/) for keyless, pay-per-request access using USDC on Base. Instead of managing API keys, your agent pays for each request directly from its onchain wallet. This makes x402 ideal for autonomous agents and systems that already hold assets onchain.

## How it works

1. Send a request with the `x-402-auth: true` header — no API key needed.
2. Receive a `402 Payment Required` response containing payment details, including the current `maxAmountRequired`.
3. Sign a USDC payment on Base using your agent's wallet.
4. Resend the original request with the `X-Payment` proof header attached.
5. Receive a `200` response with the requested data.

The [`x402`](https://www.npmjs.com/package/x402) JavaScript and Python libraries handle this payment flow automatically, so you don't need to implement the handshake manually.

## Quick start

Install the x402 client library and make your first request:

<CodeGroup>
  ```javascript javascript theme={null}
  import { wrapAxios } from "x402/axios";
  import axios from "axios";
  import { createWalletClient, http } from "viem";
  import { privateKeyToAccount } from "viem/accounts";
  import { base } from "viem/chains";

  const account = privateKeyToAccount(process.env.PRIVATE_KEY);
  const walletClient = createWalletClient({
    account,
    chain: base,
    transport: http(),
  });

  const client = wrapAxios(axios, walletClient);

  const response = await client.get("https://api.vaults.fyi/v2/vaults", {
    headers: { "x-402-auth": "true" },
  });
  ```

  ```python python theme={null}
  from x402.client import Client

  client = Client(private_key=PRIVATE_KEY, chain="base")

  response = client.get(
      "https://api.vaults.fyi/v2/vaults",
      headers={"x-402-auth": "true"},
  )
  ```
</CodeGroup>

For a complete working example, see the [Agentic DeFi repo](https://github.com/WallfacerLabs/agentic_defi).

## Pricing

All prices are in USDC on Base, charged per request. Payment is in USDC raw units (6 decimals) — for example, `5000` = \$0.005 USDC. The `402` response always contains the current `maxAmountRequired`. Prices are subject to change.

| Price   | Endpoints                                                                                |
| ------- | ---------------------------------------------------------------------------------------- |
| \$0.005 | `/v2/networks`, `/v2/vaults`, `/v2/tags`, `/v2/assets`, `/v2/curators`                   |
| \$0.01  | `/v2/vaults/{network}/{address}`, `/v2/vaults/{network}/{address}/performance`           |
| \$0.02  | `/v2/detailed-vaults/{network}/{address}`, `/v2/positions/{address}`                     |
| \$0.025 | `/v2/deposit-options/{address}`, `/v2/idle-assets/{address}`, `/v2/best-vault/{address}` |
| \$0.05  | `/v2/transactions/*`, `/v2/transactions/rewards/claim/{address}`                         |
| \$0.75  | `/v2/detailed-vaults` (paginated list of all vaults)                                     |
| Free    | `/v2/health`                                                                             |

<Warning>
  `/v2/historical/*` endpoints are not available via x402 and require an API key. [Sign up](https://portal.vaults.fyi/signup) to get a key and access historical data endpoints.
</Warning>
