From eaee87e73decb643939ddf3ce64cd6d6373d71e2 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sat, 5 Dec 2020 16:21:42 +0100 Subject: [PATCH 1/1] update API documentation * remove traces of HTML output * add details on artificial objects (see also #1671) * add geometry output documentation for lookup * deprecate query by ID via reverse endpoint * remove /search/ query format, no longer supported * explain better what reverse geocoding does * lots of smaller fixes to wording --- docs/api/Details.md | 46 +++++++++++++------------ docs/api/Lookup.md | 15 +++++++++ docs/api/Output.md | 81 ++++++++++++++++++++++++++++----------------- docs/api/Reverse.md | 51 +++++++++++++++++----------- docs/api/Search.md | 52 ++++++++++++++--------------- 5 files changed, 146 insertions(+), 99 deletions(-) diff --git a/docs/api/Details.md b/docs/api/Details.md index 2776bfe2..bf430601 100644 --- a/docs/api/Details.md +++ b/docs/api/Details.md @@ -1,19 +1,22 @@ # Place details -Lookup details about a single place by id. The default output is HTML for debugging search logic and results. +Show all details about a single place saved in the database. -**The details page (including JSON output) exists for debugging only and must not be downloaded automatically**, see [Nominatim Usage Policy](https://operations.osmfoundation.org/policies/nominatim/). +!!! warning + The details page exists for debugging only. You may not use it in scripts + or to automatically query details about a result. + See [Nominatim Usage Policy](https://operations.osmfoundation.org/policies/nominatim/). ## Parameters The details API supports the following two request formats: -``` - https://nominatim.openstreetmap.org/details?osmtype=[N|W|R]&osmid=&class= +``` xml +https://nominatim.openstreetmap.org/details?osmtype=[N|W|R]&osmid=&class= ``` -`osmtype` and `osmid` are required parameter. The type is one of node (N), way (W) +`osmtype` and `osmid` are required parameters. The type is one of node (N), way (W) or relation (R). The id must be a number. The `class` parameter is optional and allows to distinguish between entries, when the corresponding OSM object has more than one main tag. For example, when a place is tagged with `tourism=hotel` and @@ -23,36 +26,34 @@ to get exactly the one you want. If there are multiple places in the database but the `class` parameter is left out, then one of the places will be chosen at random and displayed. -``` - https://nominatim.openstreetmap.org/details?place_id= +``` xml +https://nominatim.openstreetmap.org/details?place_id= ``` -Placeids are assigned sequentially during Nominatim data import. The id for a place is different between Nominatim installation (servers) and changes when data gets reimported. Therefore it can't be used as permanent id and shouldn't be used in bug reports. +Place IDs are assigned sequentially during Nominatim data import. The ID +for a place is different between Nominatim installation (servers) and +changes when data gets reimported. Therefore it cannot be used as +a permanent id and shouldn't be used in bug reports. Additional optional parameters are explained below. ### Output format -* `format=[html|json]` - -See [Place Output Formats](Output.md) for details on each format. (Default: html) - * `json_callback=` Wrap JSON output in a callback function (JSONP) i.e. `()`. -Only has an effect for JSON output formats. * `pretty=[0|1]` -For JSON output will add indentation to make it more human-readable. (Default: 0) +Add indentation to make it more human-readable. (Default: 0) ### Output details * `addressdetails=[0|1]` -Include a breakdown of the address into elements. (Default for JSON: 0, for HTML: 1) +Include a breakdown of the address into elements. (Default: 0) * `keywords=[0|1]` @@ -60,11 +61,16 @@ Include a list of name keywords and address keywords (word ids). (Default: 0) * `linkedplaces=[0|1]` -Include details of places higher in the address hierarchy. E.g. for a street this is usually the city, state, postal code, country. (Default: 1) +Include a details of places that are linked with this one. Places get linked +together when they are different forms of the same physical object. Nominatim +links two kinds of objects together: place nodes get linked with the +corresponding administrative boundaries. Waterway relations get linked together with their +members. +(Default: 1) * `hierarchy=[0|1]` -Include details of places lower in the address hierarchy. E.g. for a city this usually a list of streets, suburbs, rivers. (Default for JSON: 0, for HTML: 1) +Include details of places lower in the address hierarchy. . (Default: 0) * `group_hierarchy=[0|1]` @@ -72,7 +78,7 @@ For JSON output will group the places by type. (Default: 0) * `polygon_geojson=[0|1]` -Include geometry of result. (Default for JSON: 0, for HTML: 1) +Include geometry of result. (Default: 0) ### Language of results @@ -86,10 +92,6 @@ comma-separated list of language codes. ## Examples -##### HTML - -[https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=38210407](https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=38210407) - ##### JSON [https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=38210407&format=json](https://nominatim.openstreetmap.org/details.php?osmtype=W&osmid=38210407&format=json) diff --git a/docs/api/Lookup.md b/docs/api/Lookup.md index 2412be1e..93729262 100644 --- a/docs/api/Lookup.md +++ b/docs/api/Lookup.md @@ -56,6 +56,21 @@ specified in the "Accept-Language" HTTP header. Either use a standard RFC2616 accept-language string or a simple comma-separated list of language codes. +### Polygon output + +* `polygon_geojson=1` +* `polygon_kml=1` +* `polygon_svg=1` +* `polygon_text=1` + +Output geometry of results as a GeoJSON, KML, SVG or WKT. Only one of these +options can be used at a time. (Default: 0) + +* `polygon_threshold=0.0` + +Return a simplified version of the output geometry. The parameter is the +tolerance in degrees with which the geometry may differ from the original +geometry. Topology is preserved in the result. (Default: 0.0) ### Other diff --git a/docs/api/Output.md b/docs/api/Output.md index c8589f64..a37cbe0b 100644 --- a/docs/api/Output.md +++ b/docs/api/Output.md @@ -2,12 +2,10 @@ The [/reverse](Reverse.md), [/search](Search.md) and [/lookup](Lookup.md) API calls produce very similar output which is explained in this section. -There is one section for each format which is selectable via the `format` -parameter. +There is one section for each format. The format correspond to what was +selected via the `format` parameter. -## Formats - -### JSON +## JSON The JSON format returns an array of places (for search and lookup) or a single place (for reverse) of the following format: @@ -41,13 +39,13 @@ a single place (for reverse) of the following format: "wikipedia": "en:London", "population": "8416535" } - }, + } ``` The possible fields are: * `place_id` - reference to the Nominatim internal database ID ([see notes](#place_id-is-not-a-persistent-id)) - * `osm_type`, `osm_id` - reference to the OSM object + * `osm_type`, `osm_id` - reference to the OSM object ([see notes](#osm-reference)) * `boundingbox` - area of corner coordinates ([see notes](#boundingbox)) * `lat`, `lon` - latitude and longitude of the centroid of the object * `display_name` - full comma-separated address @@ -62,22 +60,22 @@ The possible fields are: * `geojson`, `svg`, `geotext`, `geokml` - full geometry (only with the appropriate `polygon_*` parameter) -### JSONv2 +## JSONv2 This is the same as the JSON format with two changes: * `class` renamed to `category` * additional field `place_rank` with the search rank of the object -### GeoJSON +## GeoJSON This format follows the [RFC7946](https://geojson.org). Every feature includes a bounding box (`bbox`). -The feature list has the following fields: +The properties object has the following fields: * `place_id` - reference to the Nominatim internal database ID ([see notes](#place_id-is-not-a-persistent-id)) - * `osm_type`, `osm_id` - reference to the OSM object + * `osm_type`, `osm_id` - reference to the OSM object ([see notes](#osm-reference)) * `category`, `type` - key and value of the main OSM tag * `display_name` - full comma-separated address * `place_rank` - class search rank @@ -92,13 +90,13 @@ The feature list has the following fields: Use `polygon_geojson` to output the full geometry of the object instead of the centroid. -### GeocodeJSON +## GeocodeJSON The GeocodeJSON format follows the [GeocodeJSON spec 0.1.0](https://github.com/geocoders/geocodejson-spec). The following feature attributes are implemented: - * `osm_type`, `osm_id` - reference to the OSM object (unofficial extension) + * `osm_type`, `osm_id` - reference to the OSM object (unofficial extension, [see notes](#osm-reference)) * `type` - value of the main tag of the object (e.g. residential, restaurant, ...) * `label` - full comma-separated address * `name` - localised name of the place @@ -110,18 +108,18 @@ The following feature attributes are implemented: Use `polygon_geojson` to output the full geometry of the object instead of the centroid. -### XML +## XML The XML response returns one or more place objects in slightly different formats depending on the API call. -#### Reverse +### Reverse ``` - Bavaria, Germany @@ -148,7 +146,7 @@ attribution to OSM and the original querystring. The place information can be found in the `result` element. The attributes of that element contain: * `place_id` - reference to the Nominatim internal database ID ([see notes](#place_id-is-not-a-persistent-id)) - * `osm_type`, `osm_id` - reference to the OSM object + * `osm_type`, `osm_id` - reference to the OSM object ([see notes](#osm-reference)) * `ref` - content of `ref` tag if it exists * `lat`, `lon` - latitude and longitude of the centroid of the object * `boundingbox` - comma-separated list of corner coordinates ([see notes](#boundingbox)) @@ -159,14 +157,14 @@ The full address of the result can be found in the content of the Additional information requested with `addressdetails=1`, `extratags=1` and `namedetails=1` can be found in extra elements. -#### Search and Lookup +### Search and Lookup ``` - +https://nominatim.openstreetmap.org/reverse?lat=&lon=& ``` -There are two ways how the requested location can be specified: - -* `lat=` `lon=` - - A geographic location to generate an address for. The coordiantes must be - in WGS84 format. - -* `osm_type=[N|W|R]` `osm_id=` +where `lat` and `lon` are latitude and longitutde of a coordinare in WGS84 +projection. The API returns exactly one result or an error when the coordinate +is in an area with no OSM data coverage. - A specific OSM node(N), way(W) or relation(R) to return an address for. +Additional paramters are accepted as listed below. -In both cases exactly one object is returned. The two input parameters cannot -be used at the same time. Both accept the additional optional parameters listed -below. +!!! warning "Deprecation warning" + The reverse API used to allow address lookup for a single OSM object by + its OSM id. This use is now deprecated. Use the [Address Lookup API](../Lookup) + instead. ### Output format * `format=[xml|json|jsonv2|geojson|geocodejson]` -See [Place Output Formats](Output.md) for details on each format. (Default: html) +See [Place Output Formats](Output.md) for details on each format. (Default: xml) * `json_callback=` @@ -69,8 +81,9 @@ comma-separated list of language codes. * `zoom=[0-18]` -Level of detail required for the address. Default: 18. This is a number that corresponds -roughly to the zoom level used in map frameworks like Leaflet.js, Openlayers etc. +Level of detail required for the address. Default: 18. This is a number that +corresponds roughly to the zoom level used in XYZ tile sources in frameworks +like Leaflet.js, Openlayers etc. In terms of address details the zoom levels are as follows: zoom | address detail @@ -97,7 +110,7 @@ options can be used at a time. (Default: 0) * `polygon_threshold=0.0` -Simplify the output geometry before returning. The parameter is the +Return a simplified version of the output geometry. The parameter is the tolerance in degrees with which the geometry may differ from the original geometry. Topology is preserved in the result. (Default: 0.0) diff --git a/docs/api/Search.md b/docs/api/Search.md index 9f73594d..eada817f 100644 --- a/docs/api/Search.md +++ b/docs/api/Search.md @@ -1,30 +1,27 @@ # Search queries -The search API allows you to look up a location from a textual description. -Nominatim supports structured as well as free-form search queries. +The search API allows you to look up a location from a textual description +or address. Nominatim supports structured and free-form search queries. The search query may also contain [special phrases](https://wiki.openstreetmap.org/wiki/Nominatim/Special_Phrases) which are translated into specific OpenStreetMap (OSM) tags (e.g. Pub => `amenity=pub`). -Note that this only limits the items to be found, it's not suited to return complete -lists of OSM objects of a specific type. For those use [Overpass API](https://overpass-api.de/). +This can be used to narrow down the kind of objects to be returned. -## Parameters - -The search API has the following two formats: +!!! warning + Special phrases are not suitable to query all objects of a certain type in an + area. Nominatim will always just return a collection of the best matches. To + download OSM data by object type, use the [Overpass API](https://overpass-api.de/). -``` - https://nominatim.openstreetmap.org/search/? -``` +## Parameters -This format only accepts a free-form query string where the -parts of the query are separated by slashes. +The search API has the following format: ``` https://nominatim.openstreetmap.org/search? ``` -In this form, the query may be given through two different sets of parameters: +The search term may be specified with two different sets of parameters: * `q=` @@ -46,13 +43,13 @@ In this form, the query may be given through two different sets of parameters: Structured requests are faster but are less robust against alternative OSM tagging schemas. **Do not combine with** `q=` **parameter**. -All three query forms accept the additional parameters listed below. +Both query forms accept the additional parameters listed below. ### Output format -* `format=[html|xml|json|jsonv2|geojson|geocodejson]` +* `format=[xml|json|jsonv2|geojson|geocodejson]` -See [Place Output Formats](Output.md) for details on each format. (Default: html) +See [Place Output Formats](Output.md) for details on each format. (Default: jsonv2) * `json_callback=` @@ -96,16 +93,16 @@ Limit search results to one or more countries. `` must be the e.g. `gb` for the United Kingdom, `de` for Germany. Each place in Nominatim is assigned to one country code based -on `admin_level=2` tags, in rare cases to none (for example in -international waters outside any country). +on OSM country boundaries. In rare cases a place may not be in any country +at all, for example, in international waters. * `exclude_place_ids=` @@ -122,10 +119,11 @@ are accepted as long as they span a real box. `x` is longitude, * `bounded=[0|1]` -When a viewbox is given, restrict the result to items contained with that +When a viewbox is given, restrict the result to items contained within that viewbox (see above). When `viewbox` and `bounded=1` are given, an amenity -only search is allowed. In this case, give the special keyword for the -amenity in square brackets, e.g. `[pub]`. (Default: 0) +only search is allowed. Give the special keyword for the amenity in square +brackets, e.g. `[pub]` and a selection of objects of this type is returned. +There is no guarantee that the result is complete. (Default: 0) ### Polygon output @@ -140,7 +138,7 @@ options can be used at a time. (Default: 0) * `polygon_threshold=0.0` -Simplify the output geometry before returning. The parameter is the +Return a simplified version of the output geometry. The parameter is the tolerance in degrees with which the geometry may differ from the original geometry. Topology is preserved in the result. (Default: 0.0) @@ -154,13 +152,11 @@ address to identify your requests. See Nominatim's [Usage Policy](https://operat * `dedupe=[0|1]` Sometimes you have several objects in OSM identifying the same place or -object in reality. The simplest case is a street being split in many +object in reality. The simplest case is a street being split into many different OSM ways due to different characteristics. Nominatim will attempt to detect such duplicates and only return one match unless this parameter is set to 0. (Default: 1) - - * `debug=[0|1]` Output assorted developer debug information. Data on internals of Nominatim's -- 2.39.5