Geo & Travel
Nearest City API
Find the closest populated city to any latitude/longitude, with its distance in kilometers.
Request Headers
| Name | Required | Description |
|---|---|---|
X-RapidAPI-Key | required | Your RapidAPI key. Get one free. |
X-RapidAPI-Host | required | nearest-city.p.rapidapi.com |
Endpoints
GET
/v1/geo/nearest-city Find the nearest city to a coordinate
Parameters
| Name | Type | Required | Default | Constraints |
|---|---|---|---|---|
lat | number | required | — | -90-90 |
lon | number | required | — | -180-180 |
Code Examples
curl --request GET \
--url 'https://nearest-city.p.rapidapi.com/v1/geo/nearest-city?lat=0&lon=0' \
--header 'x-rapidapi-key: YOUR_API_KEY' \
--header 'x-rapidapi-host: nearest-city.p.rapidapi.com' const url = "https://nearest-city.p.rapidapi.com/v1/geo/nearest-city?lat=0&lon=0";
const options = {
method: "GET",
headers: {
"x-rapidapi-key": "YOUR_API_KEY",
"x-rapidapi-host": "nearest-city.p.rapidapi.com"
}
};
const response = await fetch(url, options);
const data = await response.json();
console.log(data); import requests
url = "https://nearest-city.p.rapidapi.com/v1/geo/nearest-city"
querystring = {"lat": 0, "lon": 0}
headers = {
"x-rapidapi-key": "YOUR_API_KEY",
"x-rapidapi-host": "nearest-city.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
print(response.json()) Interactive Example
$ GET /v1/geo/nearest-city?lat=35.69&lon=139.69
{"name":"Tokyo","country":"JP","latitude":35.6895,"longitude":139.69171,"population":8336599,"timezone":"Asia/Tokyo","distance_km":0.16} Subscribe & License
Access this API with commercial-ready tiers on RapidAPI. Flexible plans designed for side-projects, startups, and high-volume production architectures.
Developer Support
Need help integrating or have a custom endpoint request? Our engineering team is here to assist with authentication, payload schemas, and high-frequency rate limit increases.
System Performance
Monitored 24/7 with a 99.9% uptime SLA. Built atop cloud-native microservices with globally distributed edge caching to ensure ultra-low latency response times.
All Systems Operational