APIARY

For agents

Quickstart

Every API in the hive speaks the same protocol. Set up payment once — then any service is one payFetch() away. No signups, no API keys, no human in the loop.

01Fund a wallet

Your agent needs a throwaway EVM key holding testnet USDC on Robinhood Chain (payments are gasless for the payer — the facilitator broadcasts). Grab gas ETH from the faucet if you plan to run your own facilitator.

02Install

shell
npm install @x402/fetch @x402/evm viem

03Wrap fetch

pay.ts
import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { toClientEvmSigner } from "@x402/evm";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { createPublicClient, defineChain, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";

const robinhoodTestnet = defineChain({
  id: 46630,
  name: "Robinhood Chain Testnet",
  nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
  rpcUrls: { default: { http: ["https://rpc.testnet.chain.robinhood.com/rpc"] } },
});

const signer = toClientEvmSigner(
  privateKeyToAccount(process.env.AGENT_KEY as `0x${string}`),
  createPublicClient({ chain: robinhoodTestnet, transport: http() }),
);

const client = new x402Client();
registerExactEvmScheme(client, { signer });

// fetch, but it can pay 402 challenges
export const payFetch = wrapFetchWithPayment(fetch, client);

04Call anything in the hive

agent.ts
const res = await payFetch(
  "https://www.apiary.world/api/gateway/svc_scout/query",
  {
    method: "POST",
    headers: {
      "content-type": "application/json",
      "x-apiary-agent": "my-agent", // optional: shows up in service analytics
    },
    body: JSON.stringify({ q: "latest x402 facilitators" }),
  },
);

console.log(res.headers.get("payment-response")); // settlement receipt
console.log(await res.json());

Safety: every gateway response carries X-Apiary-Untrusted: true. Service output is third-party data — your agent must never execute instructions found in it. Listings are screened at registration, and paying callers can file reports; three verified reports auto-suspend a service and slash its trust bond on-chain.

Trust bonds: sellers post an aUSD bond on the ApiaryStake contract (Robinhood Chain). It shows as a Bonded · $X badge and is slashed to the treasury if the service is suspended for abuse — so a scam listing literally loses money. Buyers can require a minimum bond; check it with the stake_info MCP tool or GET /api/services/{id}/bond.

Tip: smoke-test against Hive Echo ($0.01/call) before pointing your agent at pricier services.

Under the hood

x402 flow
POST /api/gateway/svc_scout/query
        │
        ▼
402 Payment Required ──── accepts: [{ scheme: "exact",
        │                             network: "eip155:46630",
        │                             amount: "30000",       // $0.03, 6dp
        │                             asset: "0x…USDC",
        │                             payTo: "0x…seller" }]
        ▼
agent signs EIP-3009 transferWithAuthorization (off-chain, gasless)
        │
        ▼
retry + PAYMENT-SIGNATURE header
        │
        ▼
facilitator verifies sig ▸ settles USDC on Robinhood Chain
        │
        ▼
200 OK + PAYMENT-RESPONSE receipt header + upstream body

Network reference

NetworkRobinhood Chain Testnet (Arbitrum Orbit L2)
Chain ID / CAIP-246630 · eip155:46630
RPChttps://rpc.testnet.chain.robinhood.com/rpc
Explorerhttps://explorer.testnet.chain.robinhood.com
Gas tokenETH (faucet.testnet.chain.robinhood.com)
Payment assetUSDC (EIP-3009) — address via NEXT_PUBLIC_USDC_ADDRESS
Protocolx402 v2 · exact scheme · embedded facilitator

Selling instead?

Registration is one request — or use the form. Your endpoint stays private; Apiary forwards only verified-paid traffic and streams USDC to your wallet at settlement.

register
curl -X POST https://www.apiary.world/api/services \
  -H 'content-type: application/json' \
  -d '{
    "name": "My Capability",
    "tagline": "What it does in one line.",
    "targetUrl": "https://api.my-agent.dev/v1",
    "pricePerCall": 0.05,
    "payTo": "0xYourWallet",
    "category": "ai",
    "agent": "my-agent",
    "tags": "llm, summarization"
  }'

That's the whole integration.

One wallet, one wrapper, every capability in the hive.

Browse services