JSON Webservices
GeoNames offers most webservices in XML and JSON format. JSON has the advantage that it can be used to directly access the geonames webservice from javascript code, whereas using XML the browser will throw a security exception if an xml call to another webserver is made.
All JSON services accept an optional parameter 'callback' for a javascript function call and a parameter 'formatted=true' to format the output with linefeeds and indentation. The latter is useful to view the JSON result in a browser but should not be used in production usage (waste of bandwith).
See also: GeoNames webservices · all webservices on one table · JSON example: placename autocomplete
Cities and Placenames
Parameters
- north, south, east, west - coordinates of the bounding box
- callback - name of the javascript function (optional)
- lang - language of placenames and wikipedia urls (default = en)
- maxRows - maximal number of rows returned (default = 10)
Result
A list of cities and placenames in the bounding box, ordered by relevancy (capital/population). Placenames close together are filterered out and only the larger name is included in the resulting list.
Examples
The service is also available with XML output (the XML example).
More webservices with JSON output
- Fulltext search
- Place hierarchy: children
- Place hierarchy: hierarchy
- Place hierarchy: siblings
- Place hierarchy: neighbours
- Wikipedia: find nearby Wikipedia entries / reverse geocoding
- Wikipedia: fulltext search
- Wikipedia: articles in bounding box
- Postal codes: postal code search
- Postal codes: find nearby postal codes / reverse geocoding
- Postal codes: placename lookup with postalcode
- Reverse geocoding: street/address for the US
- Reverse geocoding: global street
- Country
- Country subdivision
Recent Earthquakes
Parameters
- north, south, east, west - coordinates of the bounding box
- callback - name of the javascript function (optional)
- date - date of earthquakes 'yyyy-MM-dd' (optional); earthquakes older or equal the given date, sorted by date, magnitude
- minMagnitude - minimal magnitude (optional)
- maxRows - maximal number of rows returned (default = 10)
Result
A list of earthquakes, ordered by magnitude.
Example
Weather
Weather data is provided in the METAR (METeorological Aerodrome Report) format.
Translations for weather conditions are available in English (default), German, Spanish, French, Italian, Czech, Dutch, Finnish, Swedish, Arabic, Portuguese, Hebrew, Polish, Russian and Bulgarian. Add the parameter 'lang=' with the language code for weather conditions in the desired language.
Units: elevation = meter, wind speed = knots, temperature = Celsius, datetime = UTC time.
Weather Stations with most recent Weather Observation
Parameters
- north, south, east, west - coordinates of the bounding box
- callback - name of the javascript function (optional)
- maxRows - maximal number of rows returned (default = 10)
Result
A list of weather stations with the most recent weather observation.
Example
Weather Station with most recent weather observation
Parameters
- ICAO - International Civil Aviation Organization (ICAO) code
- callback - name of the javascript function (optional)
Result
The weather station and the most recent weather observation for the ICAO code.
Example
Weather Station with most recent weather observation / reverse geocoding
Parameters
- lat, lng - the service will return the station closest to this given point (reverse geocoding)
- callback - name of the javascript function (optional)
- radius - search radius, only weather stations within this radius are considered. Default is about 100 km
Result
A weather station with the most recent weather observation.
Examples
An XML version is available (the XML example).