]> git.openstreetmap.org Git - nominatim.git/blob - docs/api/Reverse.md
move checkModilePresence to class, delete own debug echo
[nominatim.git] / docs / api / Reverse.md
1 # Reverse Geocoding
2
3 Reverse geocoding generates an address from a latitude and longitude or from
4 an OSM object.
5
6 ## Parameters
7
8 The main format of the reverse API is
9
10 ```
11 https://nominatim.openstreetmap.org/reverse?<query>
12 ```
13
14 There are two ways how the requested location can be specified:
15
16 * `lat=<value>` `lon=<value>`
17
18     A geographic location to generate an address for. The coordiantes must be
19     in WGS84 format.
20
21 * `osm_type=[N|W|R]` `osm_id=<value>`
22
23     A specific OSM node(N), way(W) or relation(R) to return an address for.
24
25 In both cases exactly one object is returned. The two input paramters cannot
26 be used at the same time. Both accept the additional optional parameters listed
27 below.
28
29 ### Output format
30
31 * `format=[xml|json|jsonv2|geojson|geocodejson]`
32
33 See [Place Output Formats](Output.md) for details on each format. (Default: html)
34
35 * `json_callback=<string>`
36
37 Wrap json output in a callback function ([JSONP](https://en.wikipedia.org/wiki/JSONP)) i.e. `<string>(<json>)`.
38 Only has an effect for JSON output formats.
39
40 ### Output details
41
42 * `addressdetails=[0|1]`
43
44 Include a breakdown of the address into elements. (Default: 1)
45
46
47 * `extratags=[0|1]`
48
49 Include additional information in the result if available,
50 e.g. wikipedia link, opening hours. (Default: 0)
51
52
53 * `namedetails=[0|1]`
54
55 Include a list of alternative names in the results. These may include
56 language variants, references, operator and brand. (Default: 0)
57
58
59 ### Language of results
60
61 * `accept-language=<browser language string>`
62
63 Preferred language order for showing search results, overrides the value
64 specified in the "Accept-Language" HTTP header.
65 Either use a standard RFC2616 accept-language string or a simple
66 comma-separated list of language codes.
67
68 ### Result limitation
69
70 * `zoom=[0-18]`
71
72 Level of detail required for the address. Default: 18. This is a number that corresponds
73 roughly to the zoom level used in map frameworks like Leaflet.js, Openlayers etc.
74 In terms of address details the zoom levels are as follows:
75
76  zoom | address detail
77  -----|---------------
78   3   | country
79   5   | state
80   8   | county
81   10  | city
82   14  | suburb
83   16  | street
84   18  | building
85
86
87 ### Polygon output
88
89 * `polygon_geojson=1`
90 * `polygon_kml=1`
91 * `polygon_svg=1`
92 * `polygon_text=1`
93
94 Output geometry of results as a GeoJSON, KML, SVG or WKT. Only one of these
95 options can be used at a time. (Default: 0)
96
97 * `polygon_threshold=0.0`
98
99 Simplify the output geometry before returning. The parameter is the
100 tolerance in degrees with which the geometry may differ from the original
101 geometry. Topology is preserved in the result. (Default: 0.0)
102
103 ### Other
104
105 * `email=<valid email address>`
106
107 If you are making large numbers of request please include an appropriate email
108 address to identify your requests. See Nominatim's [Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details.
109
110
111 * `debug=[0|1]`
112
113 Output assorted developer debug information. Data on internals of Nominatim's
114 "Search Loop" logic, and SQL queries. The output is (rough) HTML format.
115 This overrides the specified machine readable format. (Default: 0)
116
117
118 ## Examples
119
120 * [https://nominatim.openstreetmap.org/reverse?format=xml&lat=52.5487429714954&lon=-1.81602098644987&zoom=18&addressdetails=1](https://nominatim.openstreetmap.org/reverse?format=xml&lat=52.5487429714954&lon=-1.81602098644987&zoom=18&addressdetails=1)
121
122 ```xml
123   <reversegeocode timestamp="Fri, 06 Nov 09 16:33:54 +0000" querystring="...">
124     <result place_id="1620612" osm_type="node" osm_id="452010817">
125       135, Pilkington Avenue, Wylde Green, City of Birmingham, West Midlands (county), B72, United Kingdom
126     </result>
127     <addressparts>
128       <house_number>135</house_number>
129       <road>Pilkington Avenue</road>
130       <village>Wylde Green</village>
131       <town>Sutton Coldfield</town>
132       <city>City of Birmingham</city>
133       <county>West Midlands (county)</county>
134       <postcode>B72</postcode>
135       <country>United Kingdom</country>
136       <country_code>gb</country_code>
137     </addressparts>   
138   </reversegeocode>
139 ```
140
141 ##### Example with `format=jsonv2`
142
143 * [https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=-34.44076&lon=-58.70521](https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=-34.44076&lon=-58.70521)
144
145 ```json
146 {
147   "place_id":"134140761",
148   "licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright",
149   "osm_type":"way",
150   "osm_id":"280940520",
151 "lat":"-34.4391708",
152   "lon":"-58.7064573",
153   "place_rank":"26",
154   "category":"highway",
155   "type":"motorway",
156   "importance":"0.1",
157   "addresstype":"road",
158   "display_name":"Autopista Pedro Eugenio Aramburu, El Triángulo, Partido de Malvinas Argentinas, Buenos Aires, 1.619, Argentina",
159   "name":"Autopista Pedro Eugenio Aramburu",
160   "address":{
161     "road":"Autopista Pedro Eugenio Aramburu",
162     "village":"El Triángulo",
163     "state_district":"Partido de Malvinas Argentinas",
164     "state":"Buenos Aires",
165     "postcode":"1.619",
166     "country":"Argentina",
167     "country_code":"ar"
168   },
169   "boundingbox":["-34.44159","-34.4370994","-58.7086067","-58.7044712"]
170 }
171 ```
172
173 ##### Example with `format=geojson`
174
175 * [https://nominatim.openstreetmap.org/reverse?format=geojson&lat=44.50155&lon=11.33989](https://nominatim.openstreetmap.org/reverse?format=geojson&lat=44.50155&lon=11.33989)
176
177 ```json
178 {
179   "type": "FeatureCollection",
180   "licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
181   "features": [
182     {
183       "type": "Feature",
184       "properties": {
185         "place_id": "18512203",
186         "osm_type": "node",
187         "osm_id": "1704756187",
188         "place_rank": "30",
189         "category": "place",
190         "type": "house",
191         "importance": "0",
192         "addresstype": "place",
193         "name": null,
194         "display_name": "71, Via Guglielmo Marconi, Saragozza-Porto, Bologna, BO, Emilia-Romagna, 40122, Italy",
195         "address": {
196           "house_number": "71",
197           "road": "Via Guglielmo Marconi",
198           "suburb": "Saragozza-Porto",
199           "city": "Bologna",
200           "county": "BO",
201           "state": "Emilia-Romagna",
202           "postcode": "40122",
203           "country": "Italy",
204           "country_code": "it"
205         }
206       },
207       "bbox": [
208         11.3397676,
209         44.5014307,
210         11.3399676,
211         44.5016307
212       ],
213       "geometry": {
214         "type": "Point",
215         "coordinates": [
216           11.3398676,
217           44.5015307
218         ]
219       }
220     }
221   ]
222 }
223 ```
224
225 ##### Example with `format=geocodejson`
226
227 [https://nominatim.openstreetmap.org/reverse?format=geocodejson&lat=60.2299&lon=11.1663](https://nominatim.openstreetmap.org/reverse?format=geocodejson&lat=60.2299&lon=11.1663)
228
229 ```json
230 {
231   "type": "FeatureCollection",
232   "geocoding": {
233     "version": "0.1.0",
234     "attribution": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
235     "licence": "ODbL",
236     "query": "60.229917843587,11.16630979382"
237   },
238   "features": {
239     "type": "Feature",
240     "properties": {
241       "geocoding": {
242         "place_id": "42700574",
243         "osm_type": "node",
244         "osm_id": "3110596255",
245         "type": "house",
246         "accuracy": 0,
247         "label": "1, Løvenbergvegen, Mogreina, Ullensaker, Akershus, 2054, Norway",
248         "name": null,
249         "housenumber": "1",
250         "street": "Løvenbergvegen",
251         "postcode": "2054",
252         "county": "Akershus",
253         "country": "Norway",
254         "admin": {
255           "level7": "Ullensaker",
256           "level4": "Akershus",
257           "level2": "Norway"
258         }
259       }
260     },
261     "geometry": {
262       "type": "Point",
263       "coordinates": [
264         11.1658572,
265         60.2301296
266       ]
267     }
268   }
269 }
270 ```
271