]> git.openstreetmap.org Git - nominatim.git/blob - docs/api/Reverse.md
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / docs / api / Reverse.md
1 ## Reverse Geocoding
2
3 Reverse geocoding generates an address from a latitude and longitude.  The optional `zoom` parameter specifies the level of detail required in terms of something suitable for a Leaflet.js/OpenLayers/etc. zoom level. 
4
5 ### Parameters
6 ```
7 https://nominatim.openstreetmap.org/reverse?<query>
8 ```
9
10 * `format=[xml|json|jsonv2]`
11
12     * Output format.
13     * `jsonv2` adds the next fields to response:
14         * `place_rank`
15         * `category`
16         * `type`
17         * `importance`
18         * `addresstype`
19
20 * `json_callback=<string>`
21
22     * Wrap json output in a callback function (JSONP) i.e. `<string>(<json>)` 
23
24 * `accept-language=<browser language string>`
25
26     * Preferred language order for showing search results, overrides the value specified in the "Accept-Language" HTTP header.
27     * Either uses standard rfc2616 accept-language string or a simple comma separated list of language codes.
28
29 * `osm_type=[N|W|R]` `osm_id=<value>`
30     * A specific osm node / way / relation to return an address for
31     * **Please use this in preference to lat/lon where possible**
32
33 * `lat=<value>` `lon=<value>`
34     * The location to generate an address for
35
36 * `zoom=[0-18]`
37     * Level of detail required where `0` is country and `18` is house/building
38
39 * `addressdetails=[0|1]`
40     * defaults to 0
41     * Include a breakdown of the address into elements
42
43 * `email=<valid email address>`
44
45     * If you are making large numbers of request please include a valid email address or alternatively include your email address as part of the User-Agent string.
46     * This information will be kept confidential and only used to contact you in the event of a problem, see [Usage Policy](https://operations.osmfoundation.org/policies/nominatim/) for more details.
47
48 * `polygon_geojson=1`
49     * Output geometry of results in geojson format.
50
51 * `polygon_kml=1`
52     * Output geometry of results in kml format.
53
54 * `polygon_svg=1`
55     * Output geometry of results in svg format.
56
57 * `polygon_text=1`
58     * Output geometry of results as a WKT.
59
60 * `polygon_threshold=0.0`
61     * defaults to 0.0
62     * Simplify the output geometry before returning. The parameter is the
63       tolerance in degrees with which the geometry may differ from the original
64       geometry. Topology is preserved in the result.
65
66 * `extratags=1`
67     * Include additional information in the result if available, e.g. wikipedia link, opening hours.
68
69 * `namedetails=1`
70     * Include a list of alternative names in the results.
71     * These may include language variants, references, operator and brand.
72
73 ### Example
74
75 * [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)
76
77 ```xml
78   <reversegeocode timestamp="Fri, 06 Nov 09 16:33:54 +0000" querystring="...">
79     <result place_id="1620612" osm_type="node" osm_id="452010817">
80       135, Pilkington Avenue, Wylde Green, City of Birmingham, West Midlands (county), B72, United Kingdom
81     </result>
82     <addressparts>
83       <house_number>135</house_number>
84       <road>Pilkington Avenue</road>
85       <village>Wylde Green</village>
86       <town>Sutton Coldfield</town>
87       <city>City of Birmingham</city>
88       <county>West Midlands (county)</county>
89       <postcode>B72</postcode>
90       <country>United Kingdom</country>
91       <country_code>gb</country_code>
92     </addressparts>   
93   </reversegeocode>
94 ```
95
96 ##### Example with `format=jsonv2`
97
98 * [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)
99
100 ```json
101 {
102   "place_id":"134140761",
103   "licence":"Data © OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright",
104   "osm_type":"way",
105   "osm_id":"280940520",
106 "lat":"-34.4391708",
107   "lon":"-58.7064573",
108   "place_rank":"26",
109   "category":"highway",
110   "type":"motorway",
111   "importance":"0.1",
112   "addresstype":"road",
113   "display_name":"Autopista Pedro Eugenio Aramburu, El Triángulo, Partido de Malvinas Argentinas, Buenos Aires, 1.619, Argentina",
114   "name":"Autopista Pedro Eugenio Aramburu",
115   "address":{
116     "road":"Autopista Pedro Eugenio Aramburu",
117     "village":"El Triángulo",
118     "state_district":"Partido de Malvinas Argentinas",
119     "state":"Buenos Aires",
120     "postcode":"1.619",
121     "country":"Argentina",
122     "country_code":"ar"
123   },
124   "boundingbox":["-34.44159","-34.4370994","-58.7086067","-58.7044712"]
125 }
126 ```
127
128 ### Hierarchy
129
130 * Admin level => XML entity
131     * 2 => `<country>`
132     * 4 => `<state>`
133     * 5 => `<state_district>`
134     * 6
135     * 7 => `<county>`
136     * 8 => `<village>`
137     * 9 => `<city_district>`
138     * 10 => `<suburb>`