| GeoNames Home | Postal Codes | Download / Webservice | About | |
| Url | » | api.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 |
| postalcode_startsWith | string | the first characters or letters of a postal code |
| placename | string (postalcode or placename required) | all fields : placename,postal code, country, admin name (Important:urlencoded utf8) |
| placename_startsWith | string | the first characters of a place name |
| country | string : country code, ISO-3166 (optional) | Default is all countries. |
| countryBias | string | records from the countryBias are listed first |
| 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 |
| operator | string AND,OR (optional) | the operator 'AND' searches for all terms in the placename parameter, the operator 'OR' searches for any term, default = AND |
| charset | string (optional) | default is 'UTF8', defines the encoding used for the document returned by the web service. |
| isReduced | true or false (optional) | default is 'false', when set to 'true' only the UK outer codes are returned. Attention: the default value on the commercial servers is currently set to 'true'. It will be changed later to 'false'. |
Example http://api.geonames.org/postalCodeSearch?postalcode=9011&maxRows=10&username=demo
This service is also available in JSON format : http://api.geonames.org/postalCodeSearchJSON?postalcode=9011&maxRows=10&username=demo
Details for this service with an ajax step by step example for placename autocomplete
Webservice Type : REST
Url : api.geonames.org/findNearbyPostalCodes?
Parameters :
lat,lng, radius (in km), maxRows (default = 5),style (verbosity : SHORT,MEDIUM,LONG,FULL), country (default = all countries), localCountry (in border areas this parameter will restrict the search on the local country, value=true)
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. The result is sorted by distance. For Canada the FSA is returned (first 3 characters of full postal code)
Example:
http://api.geonames.org/findNearbyPostalCodes?lat=47&lng=9&username=demo
or
api.geonames.org/findNearbyPostalCodes?postalcode=8775&country=CH&radius=10&username=demo
This service is also available in JSON format : api.geonames.org/findNearbyPostalCodesJSON?postalcode=8775&country=CH&radius=10&username=demo
[more reverse geocoding webservices]
An other countryInfo service is available as csv output :
Example : http://api.geonames.org/countryInfoCSV?lang=it&country=DE&username=demo
Webservice Type : REST
Url : api.geonames.org/countryCode?
Parameters : lat,lng, type, lang, radius (buffer in km for closest country in coastal areas, a positive buffer expands the positiv area whereas a negative buffer reduces it);
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://api.geonames.org/countryCode?lat=47.03&lng=10.2&username=demo
[more reverse geocoding webservices]
Webservice Type : REST
Url : api.geonames.org/countrySubdivision?
Parameters : lat,lng, lang (default= names in local language), radius (buffer in km for closest country in coastal areas, a positive buffer expands the positiv area whereas a negative buffer reduces it),level (level of ADM);
Result : returns the country and the administrative subdivison (state, province,...) for the given latitude/longitude
Example http://api.geonames.org/countrySubdivision?lat=47.03&lng=10.2&username=demo
With the parameters 'radius' and 'maxRows' you get the closest subdivisions ordered by distance :
api.geonames.org/countrySubdivision?lat=47.03&lng=10.2&maxRows=10&radius=40
This service is also available in JSON format : api.geonames.org/countrySubdivisionJSON?lat=47.03&lng=10.2&username=demo
Webservice Type : REST
Url : api.geonames.org/ocean?
Parameters : lat,lng, radius (optional)
Result : returns the ocean or sea for the given latitude/longitude
Example http://api.geonames.org/ocean?lat=40.78343&lng=-43.96625&username=demo
This service is also available in JSON format : api.geonames.org/oceanJSON?lat=40.78343&lng=-43.96625&username=demo
Webservice Type : REST
Url : api.geonames.org/neighbourhood?
Parameters : lat,lng
Result : returns the neighbourhood for the given latitude/longitude
Example http://api.geonames.org/neighbourhood?lat=40.78343&lng=-73.96625&username=demo
This service is also available in JSON format : api.geonames.org/neighbourhoodJSON?lat=40.78343&lng=-73.96625&username=demo
[more reverse geocoding webservices]
Webservice Type : REST
Url : api.geonames.org/srtm3?
Parameters : lat,lng;
sample area: ca 90m x 90m
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://api.geonames.org/srtm3?lat=50.01&lng=10.2&username=demo
This service is also available in XML and JSON format :api.geonames.org/srtm3XML?lat=50.01&lng=10.2&username=demo api.geonames.org/srtm3JSON?lat=50.01&lng=10.2&username=demo
The text version of the service also accepts a list of lat/lng for the parameters 'lats' and 'lngs'. On the free server the number of points per call is limited to 20, for the premium service the limit is 2000:http://api.geonames.org/srtm3?lats=50.01,51.01&lngs=10.2,11.2&username=demo
Webservice Type : REST
Url : api.geonames.org/gtopo30?
Parameters : lat,lng;
sample area: ca 1km x 1km
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://api.geonames.org/gtopo30?lat=47.01&lng=10.2&username=demo
This service is also available in JSON format : http://api.geonames.org/gtopo30JSON?lat=47.01&lng=10.2&username=demo