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:

Parameters

Parameter Discription Example
Value
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
geobyteslocationcode
or
geobytesfqcn
or
geobytesipaddress
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
10
radius Limits the results to cities within the given radius
defaults to 40km or 25 miles
60mi
or
100km
minradius Excludes cities that are closer than the minradius from the results
defaults to 0
60mi
or
100km
latitude Latitude of nominated location
defaults to location of current connection based on IP Address if Geobytes Location Code not provided
geobyteslatitude
longitude Longitude of nominated location
defaults to location of current connection based on IP Address if Geobytes Location Code not provided
geobyteslongitude

Returns

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.
Array
Element
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