agentsvc.io

services / geocode

utilityoperational · 26 ms

Geocoding

Forward geocoding: address string → lat/lon. Reverse geocoding: lat/lon → human-readable address. Powered by OpenStreetMap Nominatim. Returns results array with display_name, lat, lon, type, and structured address object. Provide address (string) for forward, or lat + lon (numbers) for reverse.

Run free trial ↗3 free calls per day with the example input. Paid: $0.002 USDC, no limit.

Call it

import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agentsvc.io/api/v1/proxy/geocode", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({"address":"Brandenburger Tor, Berlin"}),
});
const { data, payment } = await res.json();  // payment.transaction = on-chain receipt

Input

FieldTypeDescription

Output

FieldTypeDescription
modeforward | reverse'forward' if address was geocoded, 'reverse' if coordinates were looked up
resultsarray
sourcestringAlways: 'OpenStreetMap Nominatim'

Example response (data)

{
  "mode": "forward",
  "results": [
    {
      "display_name": "Eiffel Tower, 5, Avenue Anatole France, Quartier du Gros-Caillou, Paris, Île-de-France, France",
      "lat": 48.8583736,
      "lon": 2.2922926,
      "type": "tourism",
      "address": {
        "road": "Avenue Anatole France",
        "city": "Paris",
        "state": "Île-de-France",
        "postcode": "75007",
        "country": "France",
        "country_code": "fr"
      },
      "osm_type": "way",
      "place_id": 158515771
    }
  ],
  "source": "OpenStreetMap Nominatim"
}