GET/v1/cities/nearest
Nearest cities to a coordinate, with distance and time zone (a coarse reverse geocode)
Cities of 15,000+ people only, so remote coordinates return the nearest town some distance away; distance_km says how far.
PARAMETERS
- latquery · numberREQUIRED
- Latitudee.g. 40.6413
- lonquery · numberREQUIRED
- Longitudee.g. -73.7781
- limitquery · integer
- How manye.g. 5
REQUEST
curl "https://api.apialmanac.com/v1/cities/nearest?lat=40.6413&lon=-73.7781" \ -H "X-API-Key: YOUR_KEY"
import requests
r = requests.get("https://api.apialmanac.com/v1/cities/nearest?lat=40.6413&lon=-73.7781", 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/cities/nearest?lat=40.6413&lon=-73.7781", {
headers: { "X-API-Key": "YOUR_KEY" }
});
console.log(r.status, r.headers.get("X-Gw-Remaining"));
console.log(await r.json());
RESPONSE
200OK
{
"query": {
"lat": 40.6413,
"lon": -73.7781
},
"count": 1,
"cities": [
{
"id": 5125771,
"name": "Jamaica",
"ascii_name": "Jamaica",
"country": "US",
"admin1": "New York",
"admin1_code": "NY",
"lat": 40.6915,
"lon": -73.8057,
"population": 216866,
"elevation_m": 11,
"timezone": "America/New_York",
"offset": "-04:00",
"abbreviation": "EDT",
"local_time": "2026-10-09T12:30:00-04:00",
"distance_km": 6.1,
"bearing": 338
}
],
"attribution": "City data © GeoNames (geonames.org), CC BY 4.0"
}