A node.js server used to get the biggest or the closest cities based on a given HTTP request.
All responses from the GeonamesServer include required headers to be CORS compliant
The GeonamesServer supports JSONP requests.
The callback parameter is callback
.
Request
/ip?ip=5.49.69.114&callback=myFunction
Response
json
myfunction({
"score": 583087.56,
"geonameid": 2988998,
"name": "Oullins",
"country": {
"name": "France",
"code": "FR"
},
"timezone": "Europe/Paris",
"feature": {
"class": "P",
"code": "PPL"
},
"population": 25592,
"location": {
"latitude": 45.71774,
"longitude": 4.80382
},
"names": [
"oullins",
"oullins"
],
"admin1Code": "B9",
"admin2Code": 69,
"admin3Code": 691,
"admin4Code": 69149,
"updatedOn": "2012-01-18",
"region": {
"code": "FR.B9",
"name": "Rhône-Alpes"
}
});
The following is a list of available routes. All these routes can only be accessed through GET requests.
Any other methods will result in a 405 Method not allowed error.
The results will be sent with the application/json mimetype.
If the sort parameter is specified and set to closeness but the location of the request could not be determined (due to a lack of data within the GEOIP database or GEOIP module not being installed), the current sort will be replaced by the population sort.
If a mandatory parameter or unknown parameter value is detected the server will respond with a 400 Bad Request error.
Returns a quick documentation in HTML format.
Gets the list of all the cities in the database, limited to *maxresultper_page* results by default.
*maxresultper_page* is setted from configuration files or overridden with limit query parameter parameter up to 100.
sort (optional, string, default value : population) available values :
population : The results will be sorted by population.
closeness : The results will be sorted by closeness to the place the request was sent from.
name (optional, string) : Filters city whose begins with a given name.
country (optional, string) : Only cities located in countries whose name begins with this parameter will be returned.
limit (optional, string) : The number of results.
client-ip (optional, string) : This parameter is used within the closeness sort parameter to provide a custom remote IP. /city?sort=closeness&client-ip=80.12.81.19
Returns the city which geonameid value is equal to the given id.
Returns the city in which the given IP address is located
GeonamesServer can return data formated in json.
Following are the results returned for the request */city?name=paris&limit=2
json
{
"geonames": {
"totalResultsCount": "2",
"geoname": [
{
"score": 884.5834,
"geonameid": 2988507,
"name": "Paris",
"country": {
"name": "France",
"code": "FR"
},
"timezone": "Europe/Paris",
"feature": {
"class": "P",
"code": "PPLC"
},
"population": 2138551,
"location": {
"latitude": 48.85341,
"longitude": 2.3488
},
"names": [
"paris",
"baariis",
"bahliz",
"gorad paryzh",
"lungsod ng paris",
"lutece",
"lutetia",
"lutetia parisorum",
"par",
"pa-ri",
"paarys",
"palika",
"paname",
"pantruche",
"paraeis",
"paras",
"pari",
"paries",
"parigge",
"pariggi",
"parighji",
"parigi",
"pariis",
"pariisi",
"parij",
"parijs",
"paris",
"parisi",
"parixe",
"pariz",
"parize",
"parizh",
"parizh osh",
"parizh'",
"parizo",
"parizs",
"pariž",
"parys",
"paryz",
"paryzius",
"paryż",
"paryžius",
"paräis",
"parís",
"paríž",
"parîs",
"parĩ",
"parī",
"parīze",
"paříž",
"páras",
"párizs",
"ville-lumiere",
"ville-lumière",
"ba li",
"barys",
"pairisa",
"pali",
"pari",
"paris",
"parys",
"paryzh",
"perisa",
"pryz",
"pyaris",
"pyarisa",
"pyrs",
"παρίσι",
"горад парыж",
"париж",
"париж ош",
"парижь",
"париз",
"парис",
"паріж",
"փարիզ",
"פאריז",
"פריז",
"باريس",
"پارىژ",
"پاريس",
"پاریس",
"پیرس",
"ܦܐܪܝܣ",
"पॅरिस",
"पेरिस",
"पैरिस",
"প্যারিস",
"ਪੈਰਿਸ",
"પૅરિસ",
"பாரிஸ்",
"పారిస్",
"ಪ್ಯಾರಿಸ್",
"പാരിസ്",
"ปารีส",
"ཕ་རི།",
"ပါရီမြို့",
"პარიზი",
"ፓሪስ",
"ប៉ារីស",
"パリ",
"巴黎",
"파리"
],
"admin1Code": "A8",
"admin2Code": 75,
"admin3Code": 751,
"admin4Code": 75056,
"updatedOn": "2012-08-19",
"region": {
"code": "FR.A8",
"name": "Île-de-France"
}
},
{
"score": 312.7515,
"geonameid": 4717560,
"name": "Paris",
"country": {
"name": "United States",
"code": "US"
},
"timezone": "America/Chicago",
"feature": {
"class": "P",
"code": "PPLA2"
},
"population": 25171,
"location": {
"latitude": 33.66094,
"longitude": -95.55551
},
"names": [
"paris",
"prx",
"paris",
"parizh",
"barys",
" tksas",
"parys",
" tgzas",
"париж",
"парис",
"باريس، تكساس",
"پاریس، تگزاس"
],
"admin1Code": "TX",
"admin2Code": 277,
"admin3Code": "",
"admin4Code": "",
"updatedOn": "2011-05-14",
"region": {
"code": "US.TX",
"name": "Texas"
}
}
]
}
}