| GeoNames Home | Postal Codes | Download / Webservice | About | |
Add this page to del.icio.us
|
GeoNames is using ISO-3166 alpha2 country codes.
In case of questions or troubles you might find help in our forum.
GeoNames is mainly using REST webservices.
Important:
* Don't forget to url encode string parameters containing special characters or spaces. (Faq entry on url encoding)
* Use the JSON services if you want to use GeoNames from javascript, as most browsers do not allow to call xml services from ANOTHER server.
This work is licensed under a
Creative Commons Attribution 3.0 License.
Paypal Donations are welcome.
| Url | » | ws.geonames.org/postalCodeSearch? |
| Result | » | returns a list of postal codes and places for the placename/postalcode query as xml document For the US the first returned zip code is determined using zip code area shapes, the following zip codes are based on the centroid. For all other supported countries all returned postal codes are based on centroids. |
| Parameter | Value | Description |
|---|---|---|
| postalcode | string (postalcode or placename required) | postal code |
| placename | string (postalcode or placename required) | all fields : placename,postal code, country, admin name (Important:urlencoded utf8) |
| country | string : country code, ISO-3166 (optional) | Default is all countries. |
| maxRows | integer (optional) | the maximal number of rows in the document returned by the service. Default is 10 |
| style | string SHORT,MEDIUM,LONG,FULL (optional) | verbosity of returned xml document, default = MEDIUM |
Example http://ws.geonames.org/postalCodeSearch?postalcode=9011&maxRows=10
This service is also available in JSON format : http://ws.geonames.org/postalCodeSearchJSON?postalcode=9011&maxRows=10
Details for this service with an ajax step by step example for placename autocomplete
Webservice Type : REST
Url : ws.geonames.org/findNearbyPostalCodes?
Parameters :
lat,lng, radius (in km), maxRows (default = 5),style (verbosity : SHORT,MEDIUM,LONG,FULL), country (default = all countries)
or
postalcode,country, radius (in Km), maxRows (default = 5)
Result : returns a list of postalcodes and places for the lat/lng query as xml document
Example:
http://ws.geonames.org/findNearbyPostalCodes?lat=47&lng=9
or
ws.geonames.org/findNearbyPostalCodes?postalcode=8775&country=CH&radius=10
This service is also available in JSON format : ws.geonames.org/findNearbyPostalCodesJSON?postalcode=8775&country=CH&radius=10
[more reverse geocoding webservices]
An other countryInfo service is available as csv output :
Example : http://ws.geonames.org/countryInfoCSV?lang=it&country=DE
Webservice Type : REST
Url : ws.geonames.org/countrycode?
Parameters : lat,lng, type, lang;
Result : returns the iso country code for the given latitude/longitude
With the parameter type=xml this service returns an xml document with iso country code and country name. The optional parameter lang can be used to specify the language the country name should be in. JSON output is produced with type=JSON
Example http://ws.geonames.org/countrycode?lat=47.03&lng=10.2
[more reverse geocoding webservices]
Webservice Type : REST
Url : ws.geonames.org/countrycode?
Parameters : lat,lng, lang (default= names in local language);
Result : returns the country and the administrative subdivison (state, province,...) for the given latitude/longitude
Example http://ws.geonames.org/countrySubdivision?lat=47.03&lng=10.2
This service is also available in JSON format : ws.geonames.org/countrySubdivisionJSON?lat=47.03&lng=10.2
[more reverse geocoding webservices]
Webservice Type : REST
Url : ws.geonames.org/srtm3?
Parameters : lat,lng;
Result : a single number giving the elevation in meters according to srtm3, ocean
areas have been masked as "no data" and have been assigned a value of -32768
Example http://ws.geonames.org/srtm3?lat=50.01&lng=10.2
This service is also available in JSON format : ws.geonames.org/srtm3JSON?lat=50.01&lng=10.2
Webservice Type : REST
Url : ws.geonames.org/gtopo30?
Parameters : lat,lng;
Result : a single number giving the elevation in meters according to gtopo30, ocean
areas have been masked as "no data" and have been assigned a value of -9999
Example http://ws.geonames.org/gtopo30?lat=47.01&lng=10.2
This service is also available in JSON format : http://ws.geonames.org/gtopo30JSON?lat=47.01&lng=10.2
http://download.geonames.org/export/dump