-
A very quick post to announce the launch of a public interface to our Gaze web gazetteer service. The motivation behind Gaze is collecting location information from users without using maps (a clunky approach with poor accessibility and licensing problems) or postcodes (which do not have universal coverage and have privacy issues as well as licensing problems). Instead the idea is to use place names to identify locations, even in the presence of ambiguity, alternate names, etc. We do this by providing a search service over a large gazetteer (2.2 million places and 3 million names), and supplying additional contextual information to disambiguate common place names. The API is very simple, with one major function and two other supporting ones.
Anyway, without further ado, here is the API. Internally we use one based on RABX, but we’ve done a special “RESTful” API for everyone else. All requests should be HTTP GETs; all parameters must be in UTF-8; and all responses are in UTF-8 plain text or comma-separated values. All calls should be passed to the URL,
http://gaze.mysociety.org/gaze-rest
selecting a particular function by specifying the HTTP parameter f, for instance
http://gaze.mysociety.org/gaze-rest?f=get_find_places_countries
Available functions are:
- get_country_from_ip
- Parameters:
- ip
- IPv4 address of a host, in dotted-quad format
Guess the country of location of a host from its IP address. The result of this call will be an ISO country code, followed by a line feed; or, if it was not possible to determine a country, a line feed on its own.
- get_find_places_countries
- No parameters.Return the list of countries for which the find_places call has a gazetteer available. The list is returned as a list of ISO country codes followed by line feeds.
- find_places
- Parameters:
- country
- ISO country code of country in which to search for places
- state
- state in which to search for places; presently this is only meaningful for country=US (United States), in which case it should be a conventional two-letter state code (AZ, CA, NY etc.); optional
- query
- query term input by the user; must be at least two characters long
- maxresults
- largest number of results to return, from 1 to 100 inclusive; optional; default 10
- minscore
- minimum match score of returned results, from 1 to 100 inclusive; optional; default 0
Returns in CSV format (as defined by this internet draft) with a one-line header a list of the following fields:
- name
- name of the place described by this row
- in-qualifier
- blank, or the name of an administrative region in which this place lies (for instance, a county)
- near-qualifier
- blank, or a list of nearby places, separated by commas
- latitude
- WGS-84 latitude of place in decimal degrees, north-positive
- longitude
- WGS-84 longitude of place in decimal degrees, east-positive
- state
- blank, or containing state code for US
- score
- match score for this place, from 0 to 100 inclusive
Enjoy! Questions and comments to hello@mysociety.org, please.
Update: we’ve now added the facilities for discovering population densities and “customary proximity” (as discussed in this post) to Gaze. The additional APIs are documented here.