Distance
Distance between two cities or coordinates.
GET
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
from_city | string | Optional | Origin city name |
from_country | string | Optional | Origin country ISO2 code |
to_city | string | Optional | Destination city name |
to_country | string | Optional | Destination country ISO2 code |
from_lat | number | Optional | Origin latitude (alternative) |
from_lng | number | Optional | Origin longitude (alternative) |
to_lat | number | Optional | Destination latitude (alternative) |
to_lng | number | Optional | Destination longitude (alternative) |
unit | string | Optional | Distance unit: km or miles (default: km) |
Provide city names (from_city/from_country and to_city/to_country) or coordinates.
Request Example
curl "https://api.localityapi.com/v1/distance?from_city=Dubai&from_country=AE&to_city=London&to_country=GB" \
-H "X-API-Key: lapi_your_key"Response
json
{
"from": {
"name": "Dubai",
"country": "AE"
},
"to": {
"name": "London",
"country": "GB"
},
"distance_km": 5486.38,
"distance_miles": 3409.08,
"query_ms": 31
}Response Fields
fromobjectOrigin point with name and countrytoobjectDestination point with name and countrydistance_kmnumberDistance in kilometersdistance_milesnumberDistance in milesquery_msintegerQuery execution time in milliseconds