Contents:
This API call provides location results for a given search phrase.
The results are derived from Nominatim with extra processing to handle additional location types (e.g. postcodes) and bounding box logic.
Search-as-you-type (autocomplete search) usage is permitted, as we are using our own installation rather than the central OSM installation which forbids such use.
Location types included are:
The ordering of results mainly comes from Nominatim.
Note: indexing of new data updates is currently paused.
Example which finds results for Downing Street (a common street name around the UK), returning GeoJSON results, limited to the British Isles / UK.
https://api.cyclestreets.net/v2/geocoder?q=downing+street&bounded=1&bbox=-6.6577,49.9370,1.7797,57.6924
Result:
{ "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "name": "Downing Street", "near": "City of Westminster, London", "bbox": "-0.1264298,51.5031644,-0.1262112,51.5031667" }, "geometry": { "type": "Point", "coordinates": [ -0.1262112, 51.5031667 ] } }, { "type": "Feature", "properties": { "name": "Downing Street", "near": "Cambridge, Cambridgeshire", "bbox": "0.1206122,52.2028319,0.1216765,52.2030956" }, "geometry": { "type": "Point", "coordinates": [ 0.1213628, 52.2030187 ] } }, … ] }
Same example, but with full geometries enabled, and specifying fields to display.
https://api.cyclestreets.net/v2/geocoder?q=downing+street&bounded=1&bbox=-6.6577,49.9370,1.7797,57.6924&geometries=1&fields=near,name,bbox,type,osmType,osmId,osmTagKey,osmTagValue
Result:
{ "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "near": "City of Westminster, London", "name": "Downing Street", "bbox": "-0.1264298,51.5031644,-0.1262112,51.5031667", "type": "OSM", "osmType": "way", "osmId": 139726517, "osmTagKey": "highway", "osmTagValue": "residential" }, "geometry": { "type": "LineString", "coordinates": [ [ -0.1264298, 51.5031644 ], [ -0.1262112, 51.5031667 ] ] } }, { "type": "Feature", "properties": { "near": "Cambridge, Cambridgeshire", "name": "Downing Street", "bbox": "0.1206122,52.2028319,0.1216765,52.2030956", "type": "OSM", "osmType": "way", "osmId": 3993066, "osmTagKey": "highway", "osmTagValue": "unclassified" }, "geometry": { "type": "LineString", "coordinates": [ [ 0.1206122, 52.2028319 ], [ 0.1213628, 52.2030187 ], [ 0.1216765, 52.2030956 ] ] } }, … ] }
Example with no results:
{ "type": "FeatureCollection", "features": [] }
These parameters are very similar to Nominatim.
Controls what information is returned for each location. It is strongly recommended to send this, so that clients receive exactly the data they need.
Available fields are:
If fields is not supplied, the default is used, which represents a sensible and useful set of fields.
The fields name,near are always returned.
Fields are returned in the ordering specified by the caller.
Unrecognised fieldnames are simply ignored rather than an error being thrown.
Returns a list of results as a GeoJSON object, as per example above.
By default the geometry will be a Point with the centrepoint, but fuller geometries can be enabled with geometries=1
as documented above.
The properties section for each feature includes the name, latitude, longitude and where the requested location is 'near'.
JSON object containing an error key and a text string.
Example error (text string will vary):
{
"error": "Empty search string"
}