Overpass query example

Ways with their nodes (recurse down)

The classic (._;>;); out; pattern: get ways together with the nodes that give them coordinates. Example: Langstrasse, Zürich.

A way only lists node IDs. Older tools and the OSM XML format expect the nodes to be in the answer too. > (recurse down) adds them.

The query

[out:json][timeout:25];
area["name"="Zürich"]["admin_level"="8"]->.a;
way["highway"]["name"="Langstrasse"](area.a);
(._;>;);
out;

Run it

Running the query…

Live result from overpass.ch, cached for up to 12 hours. Map data © OpenStreetMap contributors (ODbL).

How it works

  1. ._ is the current set: the ways of the street.
  2. > adds their nodes (and, for relations, their members).
  3. The union (._;>;); keeps both, and out; prints ways and nodes.

Variations

  • out geom; is simpler when you only need coordinates: it puts them directly on the way.
  • < recurses up: from nodes to the ways and relations that use them.

Run it from your code

curl https://api.overpass.ch/v1/YOUR_API_KEY/interpreter \
  --data-urlencode 'data@query.overpassql'

Save the query as query.overpassql. It works the same in Overpass Turbo, QGIS and JOSM.

More examples

All examples →