2018-08-06 00:38:19 +03:00
# Search queries
2018-03-19 19:10:22 +03:00
2020-12-05 18:21:42 +03:00
The search API allows you to look up a location from a textual description
or address. Nominatim supports structured and free-form search queries.
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
The search query may also contain
[special phrases ](https://wiki.openstreetmap.org/wiki/Nominatim/Special_Phrases )
2018-08-20 20:11:38 +03:00
which are translated into specific OpenStreetMap (OSM) tags (e.g. Pub => `amenity=pub` ).
2020-12-05 18:21:42 +03:00
This can be used to narrow down the kind of objects to be returned.
2018-03-19 19:10:22 +03:00
2020-12-05 18:21:42 +03:00
!!! 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/ ).
2018-03-19 19:10:22 +03:00
2020-12-05 18:21:42 +03:00
## Parameters
2018-03-19 19:10:22 +03:00
2020-12-05 18:21:42 +03:00
The search API has the following format:
2018-03-19 19:10:22 +03:00
```
https://nominatim.openstreetmap.org/search?< params >
```
2020-12-05 18:21:42 +03:00
The search term may be specified with two different sets of parameters:
2018-08-06 00:38:19 +03:00
* `q=<query>`
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
Free-form query string to search for.
2018-08-20 20:11:38 +03:00
Free-form queries are processed first left-to-right and then right-to-left if that fails. So you may search for
2021-10-18 17:53:24 +03:00
[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 ).
2018-08-20 20:11:38 +03:00
Commas are optional, but improve performance by reducing the complexity of the search.
2018-08-06 00:38:19 +03:00
* `street=<housenumber> <streetname>`
2018-08-20 20:11:38 +03:00
* `city=<city>`
* `county=<county>`
* `state=<state>`
* `country=<country>`
* `postalcode=<postalcode>`
2018-08-06 00:38:19 +03:00
2018-08-20 20:11:38 +03:00
Alternative query string format split into several parameters for structured requests.
2018-08-06 00:38:19 +03:00
Structured requests are faster but are less robust against alternative
OSM tagging schemas. **Do not combine with** `q=<query>` **parameter** .
2020-12-05 18:21:42 +03:00
Both query forms accept the additional parameters listed below.
2018-08-06 00:38:19 +03:00
### Output format
2020-12-05 18:21:42 +03:00
* `format=[xml|json|jsonv2|geojson|geocodejson]`
2018-03-19 19:10:22 +03:00
2020-12-05 18:21:42 +03:00
See [Place Output Formats ](Output.md ) for details on each format. (Default: jsonv2)
2018-03-19 19:10:22 +03:00
2022-04-08 18:13:42 +03:00
!!! note
The Nominatim service at
[https://nominatim.openstreetmap.org ](https://nominatim.openstreetmap.org )
has a different default behaviour for historical reasons. When the
`format` parameter is omitted, the request will be forwarded to the Web UI.
2018-03-19 19:10:22 +03:00
* `json_callback=<string>`
2019-05-21 14:55:16 +03:00
Wrap JSON output in a callback function ([JSONP](https://en.wikipedia.org/wiki/JSONP)) i.e. `<string>(<json>)` .
2018-08-06 00:38:19 +03:00
Only has an effect for JSON output formats.
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
### Output details
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
* `addressdetails=[0|1]`
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
Include a breakdown of the address into elements. (Default: 0)
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
* `extratags=[0|1]`
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
Include additional information in the result if available,
e.g. wikipedia link, opening hours. (Default: 0)
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
* `namedetails=[0|1]`
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
Include a list of alternative names in the results. These may include
language variants, references, operator and brand. (Default: 0)
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
### Language of results
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
* `accept-language=<browser language string>`
Preferred language order for showing search results, overrides the value
2018-08-20 20:11:38 +03:00
specified in the ["Accept-Language" HTTP header ](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language ).
2018-08-06 00:38:19 +03:00
Either use a standard RFC2616 accept-language string or a simple
comma-separated list of language codes.
### Result limitation
* `countrycodes=<countrycode>[,<countrycode>][,<countrycode>]...`
Limit search results to one or more countries. `<countrycode>` must be the
2020-04-21 18:42:12 +03:00
[ISO 3166-1alpha2 ](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 ) code,
e.g. `gb` for the United Kingdom, `de` for Germany.
2018-03-19 19:10:22 +03:00
2020-04-21 18:42:12 +03:00
Each place in Nominatim is assigned to one country code based
2020-12-05 18:21:42 +03:00
on OSM country boundaries. In rare cases a place may not be in any country
at all, for example, in international waters.
2018-03-19 19:10:22 +03:00
* `exclude_place_ids=<place_id,[place_id],[place_id]`
2018-08-06 00:38:19 +03:00
If you do not want certain OSM objects to appear in the search
result, give a comma separated list of the `place_id` s you want to skip.
2020-12-05 18:21:42 +03:00
This can be used to retrieve additional search results. For example, if a
previous query only returned a few results, then including those here would
cause the search to return other, less accurate, matches (if possible).
2018-08-06 00:38:19 +03:00
2018-03-19 19:10:22 +03:00
* `limit=<integer>`
2018-08-20 20:11:38 +03:00
Limit the number of returned results. (Default: 10, Maximum: 50)
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
* `viewbox=<x1>,<y1>,<x2>,<y2>`
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
The preferred area to find search results. Any two corner points of the box
2020-11-23 11:40:43 +03:00
are accepted as long as they span a real box. `x` is longitude,
2019-10-08 09:22:51 +03:00
`y` is latitude.
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
* `bounded=[0|1]`
2020-12-05 18:21:42 +03:00
When a viewbox is given, restrict the result to items contained within that
2018-08-20 20:11:38 +03:00
viewbox (see above). When `viewbox` and `bounded=1` are given, an amenity
2020-12-05 18:21:42 +03:00
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)
2018-08-06 00:38:19 +03:00
### Polygon output
* `polygon_geojson=1`
* `polygon_kml=1`
* `polygon_svg=1`
2018-03-19 19:10:22 +03:00
* `polygon_text=1`
2018-08-06 00:38:19 +03:00
Output geometry of results as a GeoJSON, KML, SVG or WKT. Only one of these
options can be used at a time. (Default: 0)
2018-03-19 19:10:22 +03:00
2018-05-16 00:28:39 +03:00
* `polygon_threshold=0.0`
2020-12-05 18:21:42 +03:00
Return a simplified version of the output geometry. The parameter is the
2018-08-06 00:38:19 +03:00
tolerance in degrees with which the geometry may differ from the original
geometry. Topology is preserved in the result. (Default: 0.0)
### Other
* `email=<valid email address>`
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.
* `dedupe=[0|1]`
Sometimes you have several objects in OSM identifying the same place or
2020-12-05 18:21:42 +03:00
object in reality. The simplest case is a street being split into many
2018-08-06 00:38:19 +03:00
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)
2018-03-19 19:10:22 +03:00
2018-08-06 00:38:19 +03:00
* `debug=[0|1]`
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)
## Examples
2018-03-19 19:10:22 +03:00
2018-07-09 17:06:48 +03:00
2020-03-31 21:10:03 +03:00
##### XML with kml polygon
2018-07-09 17:06:48 +03:00
2020-03-31 21:10:03 +03:00
* [https://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=xml&polygon_geojson=1&addressdetails=1 ](https://nominatim.openstreetmap.org/search?q=135+pilkington+avenue,+birmingham&format=xml&polygon_geojson=1&addressdetails=1 )
2018-03-19 19:10:22 +03:00
```xml
< searchresults timestamp = "Sat, 07 Nov 09 14:42:10 +0000" querystring = "135 pilkington, avenue birmingham" polygon = "true" >
2019-05-21 14:55:16 +03:00
< place
place_id="1620612" osm_type="node" osm_id="452010817"
boundingbox="52.548641204834,52.5488433837891,-1.81612110137939,-1.81592094898224"
lat="52.5487429714954" lon="-1.81602098644987"
display_name="135, Pilkington Avenue, Wylde Green, City of Birmingham, West Midlands (county), B72, United Kingdom"
2018-03-19 19:10:22 +03:00
class="place" type="house">
2020-03-31 21:10:03 +03:00
< geokml >
< Polygon >
< outerBoundaryIs >
< LinearRing >
< coordinates > -1.816513,52.548756599999997 -1.816434,52.548747300000002 -1.816429,52.5487629 -1.8163717,52.548756099999999 -1.8163464,52.548834599999999 -1.8164599,52.548848100000001 -1.8164685,52.5488213 -1.8164913,52.548824000000003 -1.816513,52.548756599999997< / coordinates >
< / LinearRing >
< / outerBoundaryIs >
< / Polygon >
< / geokml >
2018-03-19 19:10:22 +03:00
< house_number > 135< / house_number >
< road > Pilkington Avenue< / road >
< village > Wylde Green< / village >
< town > Sutton Coldfield< / town >
< city > City of Birmingham< / city >
< county > West Midlands (county)< / county >
< postcode > B72< / postcode >
< country > United Kingdom< / country >
< country_code > gb< / country_code >
< / place >
< / searchresults >
```
2018-07-09 17:06:48 +03:00
##### JSON with SVG polygon
[https://nominatim.openstreetmap.org/search/Unter%20den%20Linden%201%20Berlin?format=json&addressdetails=1&limit=1&polygon_svg=1 ](https://nominatim.openstreetmap.org/search/Unter%20den%20Linden%201%20Berlin?format=json&addressdetails=1&limit=1&polygon_svg=1 )
2018-03-19 19:10:22 +03:00
```json
{
"address": {
"city": "Berlin",
"city_district": "Mitte",
"construction": "Unter den Linden",
"continent": "European Union",
"country": "Deutschland",
"country_code": "de",
"house_number": "1",
"neighbourhood": "Scheunenviertel",
"postcode": "10117",
"public_building": "Kommandantenhaus",
"state": "Berlin",
"suburb": "Mitte"
},
"boundingbox": [
"52.5170783996582",
"52.5173187255859",
"13.3975105285645",
"13.3981599807739"
],
"class": "amenity",
"display_name": "Kommandantenhaus, 1, Unter den Linden, Scheunenviertel, Mitte, Berlin, 10117, Deutschland, European Union",
"importance": 0.73606775332943,
"lat": "52.51719785",
"licence": "Data \u00a9 OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright",
"lon": "13.3978352028938",
"osm_id": "15976890",
"osm_type": "way",
"place_id": "30848715",
"svg": "M 13.397511 -52.517283599999999 L 13.397829400000001 -52.517299800000004 13.398131599999999 -52.517315099999998 13.398159400000001 -52.517112099999999 13.3975388 -52.517080700000001 Z",
"type": "public_building"
}
```
2018-07-09 17:06:48 +03:00
##### JSON with address details
2019-10-01 13:37:53 +03:00
[https://nominatim.openstreetmap.org/?addressdetails=1&q=bakery+in+berlin+wedding&format=json&limit=1 ](https://nominatim.openstreetmap.org/?addressdetails=1&q=bakery+in+berlin+wedding&format=json&limit=1 )
2018-03-19 19:10:22 +03:00
```json
{
"address": {
"bakery": "B\u00e4cker Kamps",
"city_district": "Mitte",
"continent": "European Union",
"country": "Deutschland",
"country_code": "de",
"footway": "Bahnsteig U6",
"neighbourhood": "Sprengelkiez",
"postcode": "13353",
"state": "Berlin",
"suburb": "Wedding"
},
"boundingbox": [
"52.5460929870605",
"52.5460968017578",
"13.3591794967651",
"13.3591804504395"
],
"class": "shop",
"display_name": "B\u00e4cker Kamps, Bahnsteig U6, Sprengelkiez, Wedding, Mitte, Berlin, 13353, Deutschland, European Union",
"icon": "https://nominatim.openstreetmap.org/images/mapicons/shopping_bakery.p.20.png",
"importance": 0.201,
"lat": "52.5460941",
"licence": "Data \u00a9 OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright",
"lon": "13.35918",
"osm_id": "317179427",
"osm_type": "node",
"place_id": "1453068",
"type": "bakery"
}
2018-05-16 00:28:39 +03:00
```
2018-07-09 17:06:48 +03:00
##### GeoJSON
[https://nominatim.openstreetmap.org/search?q=17+Strada+Pictor+Alexandru+Romano%2C+Bukarest&format=geojson ](https://nominatim.openstreetmap.org/search?q=17+Strada+Pictor+Alexandru+Romano%2C+Bukarest&format=geojson )
```json
{
"type": "FeatureCollection",
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
"features": [
{
"type": "Feature",
"properties": {
"place_id": "35811445",
"osm_type": "node",
"osm_id": "2846295644",
"display_name": "17, Strada Pictor Alexandru Romano, Bukarest, Bucharest, Sector 2, Bucharest, 023964, Romania",
"place_rank": "30",
"category": "place",
"type": "house",
"importance": 0.62025
},
"bbox": [
26.1156689,
44.4354754,
26.1157689,
44.4355754
],
"geometry": {
"type": "Point",
"coordinates": [
26.1157189,
44.4355254
]
}
}
]
}
```
##### GeocodeJSON
[https://nominatim.openstreetmap.org/search?q=%CE%91%CE%B3%CE%AF%CE%B1+%CE%A4%CF%81%CE%B9%CE%AC%CE%B4%CE%B1%2C+%CE%91%CE%B4%CF%89%CE%BD%CE%B9%CE%B4%CE%BF%CF%82%2C+Athens%2C+Greece&format=geocodejson ](https://nominatim.openstreetmap.org/search?q=%CE%91%CE%B3%CE%AF%CE%B1+%CE%A4%CF%81%CE%B9%CE%AC%CE%B4%CE%B1%2C+%CE%91%CE%B4%CF%89%CE%BD%CE%B9%CE%B4%CE%BF%CF%82%2C+Athens%2C+Greece&format=geocodejson )
```json
{
"type": "FeatureCollection",
"geocoding": {
"version": "0.1.0",
"attribution": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
"licence": "ODbL",
"query": "Αγία Τριάδα, Αδωνιδος, Athens, Greece"
},
"features": [
{
"type": "Feature",
"properties": {
"geocoding": {
"type": "place_of_worship",
"label": "Αγία Τριάδα, Αδωνιδος, Άγιος Νικόλαος, 5º Δημοτικό Διαμέρισμα Αθηνών, Athens, Municipality of Athens, Regional Unit of Central Athens, Region of Attica, Attica, 11472, Greece",
"name": "Αγία Τριάδα",
"admin": null
}
},
"geometry": {
"type": "Point",
"coordinates": [
23.72949633941,
38.0051697
]
}
}
]
}
2018-08-06 00:38:19 +03:00
```