Fetch JSON
POST /api/fetch-jsonFetch a public URL and return its JSON response body as parsed JSON, with the final URL after redirects and the content type. Send POST /api/fetch-json with the required field url and pay $0.002 per call over x402 or MPP (there is no free tier). It returns a JSON object with url, finalUrl, contentType, bytes, json and 1 more.
GET only, up to 2MB, private and internal addresses refused (including after redirects). The body is third-party data, and the answer marks it untrustedContent. A non-JSON body is refused, not guessed at.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
url | string | yes | Public http(s) URL that answers JSON Also accepted as link, uri, href, page. |
Example request
curl -i -X POST https://agent402.tools/api/fetch-json \
-H "Content-Type: application/json" \
-d '{"url":"https://agent402.tools/health"}'Without payment this returns HTTP 402 Payment Required with the exact price for fetch-json; any x402 v2 or MPP client pays it and retries.
Watch a call get paid
POST /api/fetch-json$0.002 USDCPAYMENT-SIGNATUREon 14 chains200 OKAgent402-ReceiptEd25519Example response
{
"url": "https://agent402.tools/health",
"finalUrl": "https://agent402.tools/health",
"contentType": "application/json; charset=utf-8",
"bytes": 54,
"json": {
"ok": true,
"meta": {
"build": "9c963ab"
}
},
"untrustedContent": true
}| Field | Type | Always present | In the example |
|---|---|---|---|
url | string | yes | https://agent402.tools/health |
finalUrl | string | yes | https://agent402.tools/health |
contentType | string | yes | application/json; charset=utf-8 |
bytes | number | yes | 54 |
json | object | yes | 2 fields: ok, meta |
untrustedContent | boolean | yes | true |
From an MCP client
catalog.call {
"slug": "fetch-json",
"params": {
"url": "https://agent402.tools/health"
}
}The hosted connector at https://agent402.tools/mcp needs a payment for fetch-json; the stdio package pays it from a wallet or from an AGENT402_CREDITS_KEY issued earlier. Local install: npx -y agent402-mcp@0.14.0.
Errors and behavior
urlis required. An input the tool rejects returns an HTTP 4xx whose body carrieserror,tool,expected,requiredandexample, so the caller can correct it.- A paid call that ends in any status of 400 or above is not charged over x402, MPP or a prepaid credits key: settlement runs after the tool and only on a successful response. The exception is a Tempo push credential, a transfer the buyer sent before the call: it settles before the tool runs, so if the tool then fails the payment is recorded as a refund owed to the paying wallet.
- Wallet-only: this tool reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key issued earlier (
Authorization: Bearer a402_...) also pays it. - A
GETorHEADto /api/fetch-json returns the same 402 quote, so the price can be read without a body. - An
Idempotency-Keyheader makes a retried paid call replay the first 200 instead of charging again (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.002" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/fetch-json", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"url": "https://agent402.tools/health"
}),
});Related tools
HTTP check
Check any public URL: status code, latency, final URL after redirects, and response headers.
A2A Agent Card fetch
Discover and fetch a site's A2A (Agent2Agent protocol) Agent Card - tries /.well-known/agent-card.json then.
ASN + IP geolocation
Look up the Autonomous System (ASN), prefix, country, registry, and allocation date for an IPv4 address.
Certificate transparency search
Search public Certificate Transparency logs for every cert issued to a domain.
DKIM key lookup
Fetch and parse a DKIM public-key record at <selector>._domainkey.<domain> (RFC 6376).
DMARC check
Fetch and validate a domain's DMARC policy at _dmarc.<domain> (RFC 7489).