The Geobytes Get Nearby Cities API provides a list of cities that are geographically close to the nominated city. You can use it either client-side or server-side to programmatically determine the cities that are in the vicinity of given location, given the locations fully qualified city name, a Geobytes Location Code, or an IP Address. In JavaScript, for example you might access this service like this:
Which produces an output of something like this: Nearby Cities
Miles Kms City Bearing Direction
BTW If you would like to see a live real life example, then please checkout our IP Locator Page, and perhaps view the page's source. Alternatively, to use the API server-side you might approach it something like we have here in this PHP example:
   function getIP() {
         if (array_key_exists($key, $_SERVER) === true) {
            foreach (explode(',', $_SERVER[$key]) as $ip) {
               if (filter_var($ip, FILTER_VALIDATE_IP) !== false) {
                  return $ip;

$tags=json_decode(file_get_contents(''. getIP()), true);
echo PHP_EOL ;


Parameter Discription Example
locationcode Either of
* Geobytes Location Code
* Fully Qualified City Name
* IP Address
defaults to the location of current connection based on IP Address if optional Latitude and Longitude not provided
callback Used by JSON-P AJAX Calls. If unsure, just pass in a question mark as the call back ?
limit Optionally limit the number of rows returned
defaults to 10
radius Limits the results to cities within the given radius
defaults to 40km or 25 miles
minradius Excludes cities that are closer than the minradius from the results
defaults to 0
latitude Latitude of nominated location
defaults to location of current connection based on IP Address if Geobytes Location Code not provided
longitude Longitude of nominated location
defaults to location of current connection based on IP Address if Geobytes Location Code not provided


The response is a list of cities in the form of a JSON array of arrays - with each array being the following details of the nearby city. This link will open a new window containing sample results based on your current location.
Contains Description
[0] Bearing The compass bearing in degrees from the nominated city to the nearby city
[1] City Name The name of the nearby city
[2] Region or State Code The two letter region or state code
[3] Country Name The name of the nearby city's country
[4] Direction The rough direction rounded to one of the ordinal (or intercardinal) directions
[5] Nautical Miles Distance in Nautical Miles
[6] Internet Code The two letter Internet Code of the nearby City's Country
[7] Kilometres The distance in Kilometres
[8] Latitude The Latitude of the nearby city
[9] Geobytes Location Code The Geobytes Location Code of the nearby city
[10] Longitude The Longitude of the nearby city
[11] Miles The distance in Miles
[12] Region or State The name of the region or state of the nearby city

– because everybody's somewhere