End-to-end test

Payment flow test client

Test the complete APIHub flow: connect your wallet, register autonomously, search the marketplace, and make a paid API call through the proxy.

What you need to get started

Connect any supported wallet to sign transactions on the Base network.

  • A wallet -- MetaMask, Coinbase Wallet, Rabby, Phantom, Trust, or Frame
  • Base network (chain ID 8453)
  • USDC on Base for the payment step (even $1 is enough)
  • A small amount of ETH on Base for gas (under $0.01)

2 endpoints available

1

Connect wallet

2

Get registration challenge

3

Sign challenge message

4

Register and receive API key

5

Search for APIs

6

Request paid API (expect 402)

7

Sign x402 payment and retry

How this works in production

In a real agent workflow, @x402/fetch handles the 402 challenge-response automatically. Or use prepaid credits for zero-gas calls.

import { createX402Client } from "@x402/fetch";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { base } from "viem/chains";

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

const client = createX402Client({ walletClient });

const res = await client.fetch(
  "https://proxy.apihub.io/hash-service/hash/sha256",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer ahk_your_key",
      "Content-Type": "application/json",
    },
    body: '{"input":"hello from APIHub test client"}',
  }
);

const data = await res.json();