X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/5683f556467650ef06949187fc2822c3658b97c5..edb1eec46d0fd222f9b30e0e3d62e906c1c9059e:/docs/api/Search.md diff --git a/docs/api/Search.md b/docs/api/Search.md index b54c5302..da2a96b0 100644 --- a/docs/api/Search.md +++ b/docs/api/Search.md @@ -8,12 +8,12 @@ The search query may also contain which are translated into specific OpenStreetMap (OSM) tags (e.g. Pub => `amenity=pub`). This can be used to narrow down the kind of objects to be returned. -!!! warning +!!! note 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/). -## Parameters +## Endpoint The search API has the following format: @@ -21,35 +21,62 @@ The search API has the following format: https://nominatim.openstreetmap.org/search? ``` -The search term may be specified with two different sets of parameters: +!!! danger "Deprecation warning" + The API can also be used with the URL + `https://nominatim.openstreetmap.org/search.php`. This is now deprecated + and will be removed in future versions. + +The query term can be given in two different forms: free-form or structured. + +### Free-form query + +| Parameter | Value | +|-----------| ----- | +| q | Free-form query string to search for | -* `q=` +In this form, the query can be unstructured. +Free-form queries are processed first left-to-right and then right-to-left if that fails. So you may search for +[pilkington avenue, birmingham](https://nominatim.openstreetmap.org/search?q=pilkington+avenue,birmingham) as well as for +[birmingham, pilkington avenue](https://nominatim.openstreetmap.org/search?q=birmingham,+pilkington+avenue). +Commas are optional, but improve performance by reducing the complexity of the search. - Free-form query string to search for. - Free-form queries are processed first left-to-right and then right-to-left if that fails. So you may search for - [pilkington avenue, birmingham](https://nominatim.openstreetmap.org/search?q=pilkington+avenue,birmingham) as well as for - [birmingham, pilkington avenue](https://nominatim.openstreetmap.org/search?q=birmingham,+pilkington+avenue). - Commas are optional, but improve performance by reducing the complexity of the search. +The free-form may also contain special phrases to describe the type of +place to be returned or a coordinate to search close to a position. -* `amenity=` -* `street= ` -* `city=` -* `county=` -* `state=` -* `country=` -* `postalcode=` +### Structured query - Alternative query string format split into several parameters for structured requests. - Structured requests are faster but are less robust against alternative - OSM tagging schemas. **Do not combine with** `q=` **parameter**. +| Parameter | Value | +|----------- | ----- | +| amenity | name and/or type of POI | +| street | housenumber and streetname | +| city | city | +| county | county | +| state | state | +| country | country | +| postalcode | postal code | + +The structured form of the search query allows to lookup up an address +that is already split into its components. Each parameter represents a field +of the address. All parameters are optional. You should only use the ones +that are relevant for the address you want to geocode. + +!!! Attention + Cannot be combined with the `q=` parameter. Newer versions of + the API will return an error if you do so. Older versions simply return + unexpected results. + +## Parameters -Both query forms accept the additional parameters listed below. +The following parameters can be used to further restrict the search and +change the output. They are usable for both forms of the search query. ### Output format -* `format=[xml|json|jsonv2|geojson|geocodejson]` +| Parameter | Value | Default | +|-----------| ----- | ------- | +| format | one of: `xml`, `json`, `jsonv2`, `geojson`, `geocodejson` | `jsonv2` | -See [Place Output Formats](Output.md) for details on each format. (Default: jsonv2) +See [Place Output Formats](Output.md) for details on each format. !!! note The Nominatim service at @@ -57,52 +84,150 @@ See [Place Output Formats](Output.md) for details on each format. (Default: json has a different default behaviour for historical reasons. When the `format` parameter is omitted, the request will be forwarded to the Web UI. -* `json_callback=` -Wrap JSON output in a callback function ([JSONP](https://en.wikipedia.org/wiki/JSONP)) i.e. `()`. +| Parameter | Value | Default | +|-----------| ----- | ------- | +| json_callback | function name | _unset_ | + +When given, then JSON output will be wrapped in a callback function with +the given name. See [JSONP](https://en.wikipedia.org/wiki/JSONP) for more +information. + Only has an effect for JSON output formats. +| Parameter | Value | Default | +|-----------| ----- | ------- | +| limit | number | 10 | + +Limit the maximum number of returned results. Cannot be more than 40. +Nominatim may decide to return less results than given, if additional +results do not sufficiently match the query. + + ### Output details -* `addressdetails=[0|1]` +| Parameter | Value | Default | +|-----------| ----- | ------- | +| addressdetails | 0 or 1 | 0 | + +When set to 1, include a breakdown of the address into elements. +The exact content of the address breakdown depends on the output format. -Include a breakdown of the address into elements. (Default: 0) +!!! tip + If you are interested in a stable classification of address categories + (suburb, city, state, etc), have a look at the `geocodejson` format. + All other formats return classifications according to OSM tagging. + There is a much larger set of categories and they are not always consistent, + which makes them very hard to work with. -* `extratags=[0|1]` +| Parameter | Value | Default | +|-----------| ----- | ------- | +| extratags | 0 or 1 | 0 | -Include additional information in the result if available, -e.g. wikipedia link, opening hours. (Default: 0) +When set to 1, the response include any additional information in the result +that is available in the database, e.g. wikipedia link, opening hours. -* `namedetails=[0|1]` +| Parameter | Value | Default | +|-----------| ----- | ------- | +| namedetails | 0 or 1 | 0 | -Include a list of alternative names in the results. These may include -language variants, references, operator and brand. (Default: 0) +When set to 1, include a full list of names for the result. These may include +language variants, older names, references and brand. ### Language of results -* `accept-language=` +| Parameter | Value | Default | +|-----------| ----- | ------- | +| accept-language | browser language string | content of "Accept-Language" HTTP header | + +Preferred language order for showing search results. This may either be +a simple comma-separated list of language codes or have the same format +as the ["Accept-Language" HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language). + +!!! tip + First-time users of Nominatim tend to be confused that they get different + results when using Nominatim in the browser versus in a command-line tool + like wget or curl. The command-line tools + usually don't send any Accept-Language header, prompting Nominatim + to show results in the local language. Browsers on the contratry always + send the currently chosen browser language. -Preferred language order for showing search results, overrides the value -specified in the ["Accept-Language" HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language). -Either use a standard RFC2616 accept-language string or a simple -comma-separated list of language codes. +### Result restriction -### Result limitation +There are two ways to influence the results. *Filters* exclude certain +kinds of results completely. *Boost parameters* only change the order of the +results and thus give a preference to some results over others. -* `countrycodes=[,][,]...` +| Parameter | Value | Default | +|-----------| ----- | ------- | +| countrycodes | comma-separated list of country codes | _unset_ | -Limit search results to one or more countries. `` must be the -[ISO 3166-1alpha2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code, -e.g. `gb` for the United Kingdom, `de` for Germany. +Filer that limits the search results to one or more countries. +The country code must be the +[ISO 3166-1alpha2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code +of the country, e.g. `gb` for the United Kingdom, `de` for Germany. Each place in Nominatim is assigned to one country code based on OSM country boundaries. In rare cases a place may not be in any country -at all, for example, in international waters. +at all, for example, when it is in international waters. These places are +also excluded when the filter is set. -* `exclude_place_ids=,,,` | _unset_ | -* `limit=` - -Limit the number of returned results. (Default: 10, Maximum: 50) +Boost parameter which focuses the search on the given area. +Any two corner points of the box are accepted as long as they make a proper +box. `x` is longitude, `y` is latitude. +| Parameter | Value | Default | +|-----------| ----- | ------- | +| bounded | 0 or 1 | 0 | -* `viewbox=,,,` +When set to 1, then it turns the 'viewbox' parameter (see above) into +a filter parameter, excluding any results outside the viewbox. -The preferred area to find search results. Any two corner points of the box -are accepted as long as they span a real box. `x` is longitude, -`y` is latitude. - - -* `bounded=[0|1]` - -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. Give the special keyword for the amenity in square +When `bounded=1` is given and the viewbox is small enough, then an amenity-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) +There is no guarantee that the result returns all objects in the area. ### Polygon output -* `polygon_geojson=1` -* `polygon_kml=1` -* `polygon_svg=1` -* `polygon_text=1` +| Parameter | Value | Default | +|-----------| ----- | ------- | +| polygon_geojson | 0 or 1 | 0 | +| polygon_kml | 0 or 1 | 0 | +| polygon_svg | 0 or 1 | 0 | +| polygon_text | 0 or 1 | 0 | -Output geometry of results as a GeoJSON, KML, SVG or WKT. Only one of these -options can be used at a time. (Default: 0) +Add the full geometry of the place to the result output. Output formats +in GeoJSON, KML, SVG or WKT are supported. Only one of these +options can be used at a time. -* `polygon_threshold=0.0` +| Parameter | Value | Default | +|-----------| ----- | ------- | +| polygon_threshold | floating-point number | 0.0 | -Return a simplified version of the output geometry. The parameter is the +When one of the polygon_* outputs is chosen, return a simplified version +of the output geometry. The parameter describes the tolerance in degrees with which the geometry may differ from the original -geometry. Topology is preserved in the result. (Default: 0.0) +geometry. Topology is preserved in the geometry. ### Other -* `email=` +| Parameter | Value | Default | +|-----------| ----- | ------- | +| email | valid email address | _unset_ | If you are making large numbers of request please include an appropriate email -address to identify your requests. See Nominatim's [Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details. +address to identify your requests. See Nominatim's +[Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details. -* `dedupe=[0|1]` +| Parameter | Value | Default | +|-----------| ----- | ------- | +| dedupe | 0 or 1 | 1 | Sometimes you have several objects in OSM identifying the same place or 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) +attempt to detect such duplicates and only return one match. Setting +this parameter to 0 disables this deduplication mechanism and +ensures that all results are returned. -* `debug=[0|1]` +| Parameter | Value | Default | +|-----------| ----- | ------- | +| debug | 0 or 1 | 0 | Output assorted developer debug information. Data on internals of Nominatim's -"Search Loop" logic, and SQL queries. The output is (rough) HTML format. -This overrides the specified machine readable format. (Default: 0) - +"search loop" logic, and SQL queries. The output is HTML format. +This overrides the specified machine readable format. ## Examples