Overpass API/Permanent ID

From OpenStreetMap Wiki
Jump to navigation Jump to search
Overpass API logo.svg
edit
Overpass API · Language reference · Language guide · Technical terms · Areas · Query examples · Sparse Editing · Permanent ID · FAQ · more · Web site
Servers status · Versions · Development · Technical design · Installation · XAPI compatibility layer · Public transport sketch lines · Applications · Source code and issues
Overpass turbo · Wizard · Overpass turbo shortcuts · MapCSS stylesheets · Export to GeoJSON · more · Development · Source code and issues · Web site
Overpass Ultra · Overpass Ultra extensions · MapLibre stylesheets ·more · Source code and issues · Web site

Permanent Links to OSM data

What if you want to link to a specific object in OpenStreetMap? You can but you shouldn't use an object ID, because the OSM IDs may change at any time. This may even happen rather frequently. e.g. if an object is deleted and re-added. Also, every split of a way leaves one half with a different ID than the original way.

The solution is to link to the object with a certain property, usually a certain combination of tags. If a unique object exists, you are redirected to the object's web page at openstreetmap.org. Otherwise, if for example the referred way has been split, a search result page shows all possible objects. As an bonus, you can customize both the link target and the appearance of the result page.

Link to Browse Object

A first example is the oldest German motorway, the A 555 — that is the entity Q17061 at Wikidata, so Q17061 is also a "permanent ID", and as reciprocal use it is pointing to the OSM relation 23092. A link to this motorway is for example on the German motorway project page, section A 500 to A 599.

To make linking easy when creating the wiki page, that link is encapsulated in a template. In the wiki page, just write {{DisplayRoute|network=BAB|ref=A 555}}. If you want to describe a route identified by network and ref, you can just fill the template with the values of your object.


One general advice: If you create any new templates on this wiki, suitable for Overpass Queries, please include them in the category Category:Overpass API/Templates so that people can find them and make use of them.

See also