OSM JSON

From OpenStreetMap Wiki
(Redirected from Overpass JSON)
Jump to navigation Jump to search

information sign

This article is a stub. You can help OpenStreetMap by expanding it.

Basics

OSM API JSON format is based on the Overpass API JSON format with only minor differences in the header fields (see below).

It is available since March 2020 and supported by both the Rails port (since commit openstreetmap/openstreetmap-website/commit/73c9584 GitHub) and CGImap (since version 0.8.0).


Element visibility

Elements that have been deleted/hidden will have "visible": false on them, this is normally omitted when the element is visible.

When requesting from the OSM API this will always omitted unless a history call is made.


Example OSM JSON file

Here is a shortened, pretty-printed example of a complete OSM JSON file. Not every OSM JSON file will contain all of these types of elements. See more in the notes below.

Example: https://api.openstreetmap.org/api/0.6/relation/10000000/full.json

(Note that the OSM API response is not pretty printed.)

{
  "version": "0.6",
  "generator": "CGImap 0.8.1 (6263 thorn-01.openstreetmap.org)",
  "copyright": "OpenStreetMap and contributors",
  "attribution": "http://www.openstreetmap.org/copyright",
  "license": "http://opendatacommons.org/licenses/odbl/1-0/",
  "elements": [
    {
      "type": "node",
      "id": 35352001,
      "lat": 50.2106234,
      "lon": 8.5856189,
      "timestamp": "2012-12-08T23:04:02Z",
      "version": 6,
      "changeset": 14206963,
      "user": "HoloDuke",
      "uid": 75317
    },
    {
      "type": "node",
      "id": 35352063,
      "lat": 50.2121617,
      "lon": 8.5867523,
      "timestamp": "2018-11-21T20:52:44Z",
      "version": 4,
      "changeset": 64755187,
      "user": "Jonaes",
      "uid": 4433367
    },
    {
      "type": "node",
      "id": 6772305769,
      "lat": 50.2106895,
      "lon": 8.5857061,
      "timestamp": "2019-09-04T15:05:00Z",
      "version": 1,
      "changeset": 74092935,
      "user": "Jonaes",
      "uid": 4433367,
      "tags": {
        "bicycle": "yes",
        "information": "guidepost",
        "ref": "OU.425.1",
        "tourism": "information"
      }
    },
    {
      "type": "way",
      "id": 5123563,
      "timestamp": "2019-09-04T15:05:00Z",
      "version": 7,
      "changeset": 74092935,
      "user": "Jonaes",
      "uid": 4433367,
      "nodes": [
        35352060,
        35352061,
        35352062,
        35352063,
        2056819178,
        35352001
      ],
      "tags": {
        "bicycle": "yes",
        "foot": "yes",
        "highway": "track",
        "horse": "yes",
        "lcn": "yes",
        "motor_vehicle": "agricultural;forestry",
        "surface": "asphalt",
        "tracktype": "grade1",
        "traffic_sign": "DE:260,DE:1026-36"
      }
    },
    {
      "type": "relation",
      "id": 10000000,
      "timestamp": "2019-09-18T18:21:44Z",
      "version": 2,
      "changeset": 74641141,
      "user": "HoloDuke",
      "uid": 75317,
      "members": [
        {
          "type": "node",
          "ref": 6772305769,
          "role": "sign"
        },
        {
          "type": "node",
          "ref": 35352001,
          "role": "intersection"
        },
        {
          "type": "way",
          "ref": 5123563,
          "role": "to"
        }
      ],
      "tags": {
        "bicycle": "yes",
        "colour:arrow": "green",
        "colour:back": "white",
        "colour:text": "green",
        "destination": "Friedrichsdorf;Bad Homburg",
        "destination:symbol": ";train_station",
        "distance": "8.0;4.6",
        "type": "destination_sign"
      }
    }
  ]
}

See Elements for details of the object categories.
See Map features about how real world objects are modeled and categorized.

Flavours

Overpass API

See https://dev.overpass-api.de/output_formats.html#json for details.

  • the value of the version field is a JSON number, contrary to the API that returns a string.[1]
  • JSON format is pretty-printed.
  • Contains an additional "osm3s" element with timestamp and copyright information
  • copyright, attribution and license fields vary compared to OSM API JSON format.
{
  "version": 0.6,
  "generator": "Overpass API 0.7....",
  "osm3s": {
    "timestamp_osm_base": "2020-01-01T00:00:02Z",
    "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
  },
  "elements": [

{
  "type": "relation",
  "id": 10000000,
  "members": [
    {
      "type": "node",
      "ref": 6772305769,
      "role": "sign"
    },
    {
      "type": "node",
      "ref": 35352001,
      "role": "intersection"
    },
    {
      "type": "way",
      "ref": 5123563,
      "role": "to"
    }
  ],
  "tags": {
    "bicycle": "yes",
    "colour:arrow": "green",
    "colour:back": "white",
    "colour:text": "green",
    "destination": "Friedrichsdorf;Bad Homburg",
    "destination:symbol": ";train_station",
    "distance": "8.0;4.6",
    "type": "destination_sign"
  }
}

  ]
}

Overpass API out geom

When specifying out geom, the full geometry is added to each object.[2]

{
  "version": 0.6,
  "generator": "Overpass API 0.7....",
  "osm3s": {
    "timestamp_osm_base": "2020-01-01T00:00:02Z",
    "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
  },
  "elements": [

{
  "type": "relation",
  "id": 10000000,
  "bounds": {
    "minlat": 50.2106234,
    "minlon": 8.5856189,
    "maxlat": 50.2133772,
    "maxlon": 8.5873420
  },
  "members": [
    {
      "type": "node",
      "ref": 6772305769,
      "role": "sign",
      "lat": 50.2106895,
      "lon": 8.5857061
    },
    {
      "type": "node",
      "ref": 35352001,
      "role": "intersection",
      "lat": 50.2106234,
      "lon": 8.5856189
    },
    {
      "type": "way",
      "ref": 5123563,
      "role": "to",
      "geometry": [
         { "lat": 50.2133772, "lon": 8.5873420 },
         { "lat": 50.2129946, "lon": 8.5872135 },
         { "lat": 50.2126594, "lon": 8.5870583 },
         { "lat": 50.2121634, "lon": 8.5867429 },
         { "lat": 50.2111796, "lon": 8.5860363 },
         { "lat": 50.2106234, "lon": 8.5856189 }
      ]
    }
  ],
  "tags": {
    "bicycle": "yes",
    "colour:arrow": "green",
    "colour:back": "white",
    "colour:text": "green",
    "destination": "Friedrichsdorf;Bad Homburg",
    "destination:symbol": ";train_station",
    "distance": "8.0;4.6",
    "type": "destination_sign"
  }
}

  ]
}

See also

  1. NB: Ruby on Rails openstreetmap-website defined the OSM API version number as string at least going back to ~2008. JSON output in Overpass API was added much later.
  2. https://overpass-api.de/api/interpreter?data=[out:json];relation(id:10000000);out%20geom;