End-to-end test
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.
2 endpoints available
Connect wallet
Get registration challenge
Sign challenge message
Register and receive API key
Search for APIs
Request paid API (expect 402)
Sign x402 payment and retry
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();