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

Url
http://api.geonames.org/citiesJSON?

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

JSONXML

The service is also available with XML output (the XML example).

More webservices with JSON output

Recent Earthquakes

Url
http://api.geonames.org/earthquakesJSON?

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

JSON

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

Url
http://api.geonames.org/weatherJSON?

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

JSON

Weather Station with most recent weather observation

Url
http://api.geonames.org/weatherIcaoJSON?

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

JSON: Zurich (LSZH)

Weather Station with most recent weather observation / reverse geocoding

Url
http://api.geonames.org/findNearByWeatherJSON?

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

JSONXML

An XML version is available (the XML example).