Every Overpass query answers one question: which map elements match these conditions? The simplest condition is a bounding box, a rectangle given by its south-west and north-east corners.
This query finds all cafés mapped as points in central Zürich.
The query
[out:json][timeout:25]; node["amenity"="cafe"](47.365,8.535,47.380,8.555); out;
Run it
Live result from overpass.ch, cached for up to 12 hours. Map data © OpenStreetMap contributors (ODbL).
How it works
[out:json][timeout:25];is the settings line: answer in JSON and give up after 25 seconds.nodesearches points. Ways (lines and outlines) and relations are separate element types.["amenity"="cafe"]keeps only elements with the tag amenity=cafe.(47.365,8.535,47.380,8.555)is the bounding box in the order south, west, north, east.out;prints what was found, with coordinates and tags.
Variations
- Many cafés are mapped as building outlines, not points. Use
nwrinstead ofnodeandout center;to get them too: see nodes, ways and relations at once. - The
{{bbox}}shortcut only works inside Overpass Turbo. In your own code, write the four numbers.
Run it from your code
curl https://api.overpass.ch/v1/YOUR_API_KEY/interpreter \
--data-urlencode 'data@query.overpassql'
import requests
query = open("query.overpassql").read()
r = requests.post("https://api.overpass.ch/v1/YOUR_API_KEY/interpreter",
data={"data": query}, timeout=120)
r.raise_for_status()
print(r.json()["elements"][:3])
const res = await fetch("https://api.overpass.ch/v1/YOUR_API_KEY/interpreter", {
method: "POST",
body: new URLSearchParams({ data: query }),
});
if (!res.ok) throw new Error(await res.text());
console.log(await res.json());
Save the query as query.overpassql. It works the same in Overpass Turbo, QGIS and JOSM.