GET/v1/geo/distance
Great-circle distance, bearings, midpoint and bounding box between two coordinates
Give lat2/lon2 for a second point, or bearing and distance_km to project from the first point instead. radius_km adds a bounding box around the first point, handy for "within 25 km" searches.
PARAMETERS
- lat1query · numberREQUIRED
- First point latitudee.g. 40.7128
- lon1query · numberREQUIRED
- First point longitudee.g. -74.006
- lat2query · number
- Second point latitudee.g. 51.5074
- lon2query · number
- Second point longitudee.g. -0.1278
- bearingquery · number
- Projection: initial bearing in degreese.g. 0
- distance_kmquery · number
- Projection: distance to travele.g. 0
- radius_kmquery · number
- Bounding box radius around the first pointe.g. 0
REQUEST
curl "https://api.apialmanac.com/v1/geo/distance?lat1=40.7128&lon1=-74.006" \ -H "X-API-Key: YOUR_KEY"
import requests
r = requests.get("https://api.apialmanac.com/v1/geo/distance?lat1=40.7128&lon1=-74.006", headers={"X-API-Key": "YOUR_KEY"})
print(r.status_code, r.headers.get("X-Gw-Remaining"))
print(r.json())
const r = await fetch("https://api.apialmanac.com/v1/geo/distance?lat1=40.7128&lon1=-74.006", {
headers: { "X-API-Key": "YOUR_KEY" }
});
console.log(r.status, r.headers.get("X-Gw-Remaining"));
console.log(await r.json());
RESPONSE
200OK
{
"from": {
"lat": 40.7128,
"lon": -74.006
},
"to": {
"lat": 51.5074,
"lon": -0.1278
},
"distance": {
"km": 5570.2,
"mi": 3461.2,
"nmi": 3007.7,
"m": 5570222
},
"initial_bearing": 51.2,
"final_bearing": 108.3,
"compass": "NE",
"midpoint": {
"lat": 52.3,
"lon": -41.7
},
"bounding_box": {
"south": 40.7128,
"north": 51.5074,
"west": -74.006,
"east": -0.1278
},
"note": "great-circle on a sphere of radius 6371.0088 km"
}