I'm very new to OpenStreetMap's Overpass QL API. After digging through its hefty wiki and several tutorials I get the feeling that if I want to query for a city I can use either area[name="Tbilisi"][boundary=administrative] or {{geocodeArea:Tbilisi}}. I think [boundary=administrative] helps identify it as a city or at least some kind of official entity like a state or municipality rather than, say, part of the name of a cafe. I don't know if I am right.

Following that, I should be able to get restaurants in Tbilisi with the area[name="Tbilisi"][boundary=administrative] syntax on Overpass Turbo like so:


However, it returns '"elements": []'. out count returns a total of 0.

I then tried with {{geocodeArea:Tbilisi}}:


This returned a very long list of elements, out count total is 419.

Unfortunately, I can't use {{geocodeArea:Tbilisi}} with cURL like this:

curl --globoff 'https://overpass-api.de/api/interpreter?data=[out:json];{{geocodeArea:Tbilisi}}->.searchArea;node["amenity"="restaurant"](area.searchArea);out;'

It gives:

<p><strong style="color:#FF0000">Error</strong>: line 1: parse error: Unknown type "{" </p>
<p><strong style="color:#FF0000">Error</strong>: line 1: parse error: An empty query is not allowed </p>
<p><strong style="color:#FF0000">Error</strong>: line 1: parse error: ';' expected - '{' found. </p>

(Update 8 Apr 19: As mmd mentions in the comments below, {{geocodeArea:CITY_NAME}} is Overpass Turbo syntactic sugar and cannot be used for Overpass API.) Looking into the Network tab of dev tools after running this same query in Overpass Turbo, I find this works on Overpass Turbo because it translates {{geocodeArea:Tbilisi}} to area(3601996871). But I'd like to query by city name if possible.

I don't know if I've misunderstood the query structure. If I try the area[name="CITY_NAME"] syntax with Singapore like so:

out count;

Overpass Turbo returns a total of 2221.

But with the {{geocodeArea:CITY_NAME}} syntax like this:

out count;

The total count is different. It's 2192.

What is the correct way to query for POI in a city? Preferably with cURL and by city name?

closed as too broad by Jochen Schwarze, whyzar, Evil Genius, Erik, ahmadhanb Apr 22 at 5:37

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    {{geocodeArea:Singapore}} is overpass turbo specific syntactic sugar, which is invalid syntax for Overpass API! – mmd Apr 8 at 9:02
  • If you want to query by name then you need to perform a geocoding step before to determine the relation ID, for example with the help of Nominatim. – scai Apr 8 at 9:52
  • ... and that's exactly what overpass turbo's {{geocodeArea}} does: it calls Nominatim, converts the relation number to an Overpass area id, and sends the query to the Overpass API backend server. If you don't want to use Nominatim, you need to find the correct tags for the area you're interested, like in area[name="Singapore"][boundary=administrative]. This requires you to spend some time on OSM tagging, which would be beyond the scope of this question. – mmd Apr 8 at 20:19
  • Thanks @scai. Now I understand better that I have to use both in this case. – nusantara Apr 18 at 20:35
  • Thanks @mmd. Now I understand the syntax better. – nusantara Apr 18 at 20:35