Overpass query example

Every version of an object (timeline)

List the versions of an element with timeline, then fetch each one with retro: tags, position, time and user. Example: the Matterhorn summit.

History queries are part of the Medium and Large plans. The result below runs on our server for this page.

timeline returns one entry per version of an element, with the time it was created and replaced. retro runs statements at another date. Together they give every version with its tags.

This query lists the versions of the node of the Matterhorn summit.

The query

[out:json][timeout:60];
timeline(node, 26863664);
for (t["created"]) {
  retro (_.val) {
    node(26863664);
    out meta;
  }
}

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. timeline(node, 26863664) makes one timeline element per version, with the tags refversion, created and expired.
  2. for (t["created"]) loops over the versions; _.val is the time the version was created.
  3. retro (_.val) { … } runs the block at that time, so node(26863664) returns the version of that moment.
  4. out meta; prints it with its version number, time, user and changeset.
  5. The history starts with the version that was current on 12 September 2012, here version 16 of 2011. Since then, the name changed to Cervino in 2015 and back two weeks later, and in July and August 2023 the Russian name was removed and added back nine times.

Variations

  • Only the list of versions: timeline(node, 26863664); out; is small and fast.
  • Who edited it last: node(26863664); out meta;.
  • Ways and relations work the same: timeline(way, …) and timeline(relation, …). The ID is in the address of the object on openstreetmap.org.

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 →