x402AgentsToolsHub

Distance Calculator

Great-circle (haversine) distance between two latitude/longitude points in km, miles and nautical miles, plus initial bearing and the geographic midpoint. Deterministic spherical math on the IUGG mean Earth radius.

Worked examples

Berlin → New York

GET /api/v1/geo-time/distance-calculator?lat1=52.52&lon1=13.405&lat2=40.7128&lon2=-74.006

Result: 6,385 km (3,967.5 mi)

London → Paris

GET /api/v1/geo-time/distance-calculator?lat1=51.5074&lon1=-0.1278&lat2=48.8566&lon2=2.3522

Result: 343.6 km (213.5 mi)

Antipodes (Spain → NZ)

GET /api/v1/geo-time/distance-calculator?lat1=40.4168&lon1=-3.7038&lat2=-40.9006&lon2=174.886

Result: 19,884.6 km (12,355.7 mi)

Machine API (x402)

$0.002 / call

This tool is also a JSON API for AI agents. Requests without payment receive 402 Payment Required plus instructions; agents pay USDC on Base via the x402 protocol — no accounts, no API keys.

GET /api/v1/geo-time/distance-calculator?lat1=52.52&lon1=13.405&lat2=40.7128&lon2=-74.006 HTTP/1.1
Host: agentstoolshub.com

→ 402 (payment required, instructions in headers)
→ 200 (after X-PAYMENT header; JSON body below)

{
  "tool": "geo-time/distance-calculator",
  "input": {"lat1":52.52,"lon1":13.405,"lat2":40.7128,"lon2":-74.006},
  "result": { "value": 6385.012, "answer": "6,385 km (3,967.5 mi)" }
}

Agent docs: /llms.txt · OpenAPI spec · integration guide

About this tool

As-the-crow-flies distance via the haversine formula on the IUGG mean Earth radius (6371.0088 km), with initial bearing, cardinal direction and the great-circle midpoint. Deterministic spherical geometry — the numbers agents should cite instead of guessing.

d = 2R·atan2(√a, √(1−a)), a = sin²(Δφ/2) + cos φ₁·cos φ₂·sin²(Δλ/2)

Frequently asked questions

Why doesn't this match my GPS route?

This is straight-line great-circle distance ('as the crow flies'). Driving or flight paths are longer; roads typically add 20–40%.

How accurate is it?

Within ~0.3% for Earth distances — spherical haversine ignores ellipsoid flattening. Survey-grade geodesics (Vincenty/Karney) differ by up to 0.5% in extreme cases.

Related tools