I have an xml query which starts out like this:

<osm-script output="xml" timeout="250">
  <id-query {{nominatimArea:Ridgefield Connecticut}} into="area"/>
  <!-- gather results -->

This works fine here: http://overpass-turbo.eu/s/5J7

But when I try to query using wget, it returns HTTP request sent, awaiting response... 400 Bad Request. If I resolve the query into it normalized form, then it works fine:

<osm-script output="xml" timeout="250">
  <id-query type="area" ref="2705805056" into="area"/>
  <!-- gather results -->

How can I pass the former query through a script, or how can I lookup the area in advance?

2 Answers 2


Look at the official website for more to correctly use WGET http://overpass-api.de/command_line.html

You can also to get started, try with CURL instead of WGET: it's more easy as you can copy the call you do in browser using the Network panel of your debugger (below illustrated with Google Chrome but available also on FireFox)

Google Chrome CURL copy with OverPass API

For scripting, this query Overpass Python library or this Node JS package can be interesting.

  • The place_id only matches some of the time. For example, Danbury Connecticut has a place_id of 64246176 and an osm_id of 33271879, but the sends this in the query: <id-query type="area" ref="2433271879" into="area"/>
    – brianegge
    Nov 12, 2014 at 2:36
  • place_id is a purely Nominatim internal identifier, it has absolutely no relevance outside of Nominatim, see: help.openstreetmap.org/questions/21542/nominatim-place-id
    – mmd
    Jan 4, 2015 at 16:26
  • ref="2433271879" is derived from OSM way 33271879 by adding 2400000000 to its OSM way id (in case of a relation that would be 3600000000). See wiki.openstreetmap.org/wiki/Overpass_API/….
    – mmd
    Jan 4, 2015 at 16:29

Thanks ThomasG77. I found what I was looking for. On the website, it first resolves the extended queries, and then substitutes them. The extended queries get cached, so I wasn't seeing them initially.

The first bit gets the place_id from nomination:

curl 'http://nominatim.openstreetmap.org/search?X-Requested-With=overpass-turbo&format=json&q=Ridgefield+Connecticut' -H 'Origin: http://overpass-turbo.eu' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36' -H 'Accept: */*' -H 'Connection: keep-alive' --compressed
[{"place_id":"2578289456","licence":"Data \u00a9 OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"way","osm_id":"305805056","boundingbox":["41.2371844","41.3774174","-73.5509631","-73.438191"],"lat":"41.2814842","lon":"-73.4981792","display_name":"Ridgefield, Fairfield County, Connecticut, United States of America","class":"boundary","type":"administrative","importance":0.62842337196131,"icon":"http:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_boundary_administrative.p.20.png"},{"place_id":"57921086","licence":"Data \u00a9 OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"way","osm_id":"21923588","boundingbox":["42.2668794","42.2694486","-88.3335358","-88.3264975"],"lat":"42.2694329","lon":"-88.3290606","display_name":"Connecticut Trail, Holcombville Corners, McHenry County, Illinois, 60012, United States of America","class":"highway","type":"residential","importance":0.2}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.