Geocode address
GET /api/geocode · Cached 1dResolve a free-form address or place name to coordinates: lat/lon, display name, bounding box, place type. Send GET /api/geocode with the required field q and pay $0.001 per call over x402 or MPP (there is no free tier). It returns a JSON object with query, count, results and source.
OpenStreetMap/Nominatim, no key. ?q=1600+Pennsylvania+Ave+Washington+DC&limit=1.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
q | string | yes | Free-form address or place name Also accepted as query, search, term, keyword. |
limit | number | no | Results to return, 1-10 (default 1) |
countryCodes | string | no | Comma-separated ISO-3166-1 alpha-2 codes to restrict, e.g. us,ca (optional) |
Example request
curl -i "https://agent402.tools/api/geocode?q=1600+Pennsylvania+Ave+NW%2C+Washington%2C+DC&limit=1"
Without payment this returns HTTP 402 Payment Required with the exact price for geocode; any x402 v2 or MPP client pays it and retries.
Example response
{
"query": "1600 Pennsylvania Ave NW, Washington, DC",
"count": 1,
"results": [
{
"displayName": "White House, 1600, Pennsylvania Avenue Northwest, Washington, District of Columbia, 20500, United States",
"lat": 38.8976633,
"lon": -77.0365739,
"type": "attraction",
"class": "tourism",
"importance": 0.78,
"osm": "way/238241022",
"boundingBox": {
"south": 38.8974908,
"north": 38.897829,
"west": -77.0368537,
"east": -77.0362519
}
}
],
"source": "nominatim.openstreetmap.org (ODbL)"
}
| Field | Type | Always present | In the example |
|---|---|---|---|
query | string | yes | 1600 Pennsylvania Ave NW, Washington, DC |
count | number | yes | 1 |
results | array of objects | yes | 1 item in the example |
source | string | yes | nominatim.openstreetmap.org (ODbL) |
From an MCP client
catalog.call {
"slug": "geocode",
"params": {
"q": "1600 Pennsylvania Ave NW, Washington, DC",
"limit": 1
}
}
The hosted connector at https://agent402.tools/mcp needs a payment for geocode; the stdio package pays it from a wallet or from AGENT402_CREDITS_KEY. Local install: npx -y agent402-mcp.
Errors and behavior
qis 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 is cancelled when the tool fails. 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. - Cached: an identical request within 1d is answered from cache with
X-Cache: hit. - A
POSTwith a JSON body to /api/geocode is served as this GET, with the body as the input. - 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?.(false); // keep your own spending ceiling in code
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/geocode?q=1600+Pennsylvania+Ave+NW%2C+Washington%2C+DC&limit=1");
Part of these workflows
Geocode address is one step in these 2 skill packs, each sold as a single call:
- Location intel - Point at an address (or even a rough place name) and assemble the situational brief: precise coordinates, the canonical postal address, what's within walking distance, the live weather forecast, active NWS hazard alerts, and recent seismic activity. The deterministic 'what should I know about this place right now?' workup.
- Multi-stop trip planner - Plan a multi-stop journey deterministically: geocode each stop, sum the pairwise haversine distances, estimate arrival times by adding driving hours per leg, count business days from today to each arrival, and pull the weather forecast at every US stop. Six tools - three pure-CPU (math + time), three egress (geocoding + weather) - covering the deterministic skeleton of every road-trip / sales-tour / delivery-route planning problem.
Related tools
Reverse geocode
GET /api/reverse-geocodeResolve a lat/lon to a structured postal address: road, house number, city, state, postcode, country (with ISO code). Op…
Place search
GET /api/place-searchSearch OpenStreetMap for places by keyword, optionally restricted to a bounding box or country. Returns ranked hits with…
A2A Agent Card validate
POST /api/a2a-card-validateValidate an A2A (Agent2Agent protocol) Agent Card: required fields, skill shape, transport names, capability flags - spe…
Amortization schedule
POST /api/amortizationBuild the full per-period amortization schedule for a fully-amortizing loan. Each row reports the period number, payment…
Annuity present/future value
POST /api/annuityPresent and future value of a level annuity (equal periodic payments). Supports an ordinary annuity (payments at period …
Barcode / QR decode
POST /api/barcode-decodeDecode a barcode or QR code from an image. Send a base64 PNG or JPEG (or a data: URL); returns the decoded text and the …