Pay per call (x402)#
An agent doesn't need a Layer account. It can call the API with no key and pay for each answer in USDC on Base, using x402. You get the same answer an account with a key gets, and you're charged only when the call succeeds: a 400 or any other error costs nothing.
A free key is still the cheaper way for anything you'll call often: it has no per-call price.
Prices#
| Endpoint | What it answers | Price per call |
|---|---|---|
GET /v0/match |
One market's twin on another venue, with both venues' live prices | $0.02 |
POST /v0/match |
The same for up to 50 markets | $0.25 |
GET /v0/matches |
Every live match, with prices and the best trade | $0.10 |
GET /v0/settlements |
How matched pairs settled on both venues | $0.05 |
POST /v0/profit |
Profit after both venues' fees for prices you send | $0.01 |
GET /v0/quote |
The most contracts of one matched market that clear your edge, from both live books | $0.02 |
POST /v0/size |
The largest size that clears your edge, from order books you send | $0.02 |
Every other endpoint needs a key. Inputs and answers are the same as in the API reference.
How it works#
- Call the endpoint with no key. Layer answers
402 payment_required, with the price, the network (Base) and where to pay in thePAYMENT-REQUIREDheader. - Your x402 client signs a USDC payment for that amount and calls again with it in the
PAYMENT-SIGNATUREheader. - Layer answers. Only then is the payment settled; the
PAYMENT-RESPONSEheader carries the transaction.
bash
curl -i "https://uselayer.sh/v0/match?venue=kalshi&market_id=KXFEDDECISION-26DEC-H0"
# HTTP/2 402
# payment-required: eyJ4NDAyVmVyc2lvbiI6Mi…From code#
Any x402 client works. With @x402/fetch and a wallet that holds USDC on Base:
typescript
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);
const fetchWithPayment = wrapFetchWithPaymentFromConfig(fetch, {
schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});
const res = await fetchWithPayment("https://uselayer.sh/v0/matches?category=sports&q=nba");
console.log(await res.json());From an AI assistant, an MCP wallet such as AgentCash pays for you: ask it to call https://uselayer.sh/v0/match for a market.
Where agents find Layer#
- Coinbase's x402 Bazaar, the catalog agents search for paid APIs.
- x402scan, which AgentCash reads.
/openapi.json: every paid endpoint, its inputs, an example answer and its price.
Questions, or a price that doesn't work for you: david@uselayer.sh.