Distance Calculator
Calculate the distance between two or more geographic coordinates
/v1/geo/distance
curl -X POST "https://geo.toolkitapi.io/v1/geo/distance" \
-H "Content-Type: application/json" \
-d '{
"points": [
{"lat": 40.7128, "lon": -74.006},
{"lat": 51.5074, "lon": -0.1278}
],
"unit": "km",
"method": "haversine"
}'
import httpx
resp = httpx.post(
"https://geo.toolkitapi.io/v1/geo/distance",
json={
"points": [
{"lat": 40.7128, "lon": -74.006},
{"lat": 51.5074, "lon": -0.1278}
],
"unit": "km",
"method": "haversine"
},
)
print(resp.json())
const resp = await fetch("https://geo.toolkitapi.io/v1/geo/distance", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
"points": [
{"lat": 40.7128, "lon": -74.006},
{"lat": 51.5074, "lon": -0.1278}
],
"unit": "km",
"method": "haversine"
}),
});
const data = await resp.json();
console.log(data);
# See curl example
{
"total_distance": 5570.222,
"unit": "km",
"method": "haversine",
"legs": [
{
"from_point": {"lat": 40.7128, "lon": -74.006},
"to_point": {"lat": 51.5074, "lon": -0.1278},
"distance": 5570.222
}
]
}
Try It Live
Description
How to Use
1. Provide an array of at least two coordinate points in the `points` field, each with `lat` and `lon`.
2. Optionally set `unit` to `km`, `mi`, `m`, or `nm` (default: `km`) and `method` to `haversine` or `vincenty`.
3. Send a POST request and inspect `total_distance` for the cumulative distance across all legs.
4. Use the `legs` array for individual segment distances when routing through multiple waypoints.
About This Tool
Use the Distance Calculator to compute the great-circle distance between two or more geographic coordinates using either the Haversine or Vincenty (spherical) formula. When more than two points are provided, the endpoint calculates each leg individually and returns the total distance.
This supports multiple units including kilometres, miles, metres, and nautical miles, making it suitable for logistics, travel planning, and geospatial analysis.
Why Use This Tool
- Logistics planning — Calculate shipping distances between warehouses and delivery addresses
- Travel apps — Show distance between points of interest on a map
- Geofencing — Determine if a coordinate falls within a radius of a reference point
- Fleet management — Estimate route distances for vehicle tracking
Frequently Asked Questions
What is the difference between Haversine and Vincenty?
Can I calculate multi-stop routes?
What is the maximum number of points?
Start using Distance Calculator now
Get your free API key and make your first request in under a minute.