Skip to content
GuidesBlogPlaygroundDashboard

Get feature by type and ID

elements.retrieve(intid, ElementRetrieveParams**kwargs) -> GeoJsonFeature
GET/api/v1/features/{type}/{id}

Get feature by type and ID

ParametersExpand Collapse
type: str
id: int
ReturnsExpand Collapse
class GeoJsonFeature:

GeoJSON Feature representing an OSM element. Tags from the original OSM element are flattened directly into properties (not nested under a tags key). Metadata fields @type and @id identify the OSM element type and ID within properties.

geometry: GeoJsonGeometry

GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints.

coordinates: Union[List[float], List[List[float]], List[List[List[float]]], List[List[List[List[float]]]]]

Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc.

One of the following:
List[float]

[longitude, latitude] or [longitude, latitude, elevation]

List[List[float]]

Array of [lng, lat] positions

List[List[List[float]]]

Array of linear rings / line strings

List[List[List[List[float]]]]

Array of polygons

type: Literal["Point", "LineString", "Polygon", 3 more]

Geometry type

One of the following:
"Point"
"LineString"
"Polygon"
"MultiPoint"
"MultiLineString"
"MultiPolygon"
properties: Dict[str, object]

OSM tags flattened as key-value pairs, plus @type (node/way/relation) and @id (OSM ID) metadata fields. May include distance_m for proximity queries.

type: Literal["Feature"]

Always Feature

id: Optional[str]

Compound identifier in type/osm_id format

Get feature by type and ID

import os
from plaza import Plaza

client = Plaza(
    api_key=os.environ.get("PLAZA_API_KEY"),  # This is the default and can be omitted
)
geo_json_feature = client.elements.retrieve(
    id=0,
    type="type",
)
print(geo_json_feature.id)
{
  "geometry": {
    "coordinates": [
      2.3522,
      48.8566
    ],
    "type": "Point"
  },
  "properties": {
    "@id": "bar",
    "@type": "bar",
    "amenity": "bar",
    "cuisine": "bar",
    "name": "bar"
  },
  "type": "Feature",
  "id": "node/21154906"
}
Returns Examples
{
  "geometry": {
    "coordinates": [
      2.3522,
      48.8566
    ],
    "type": "Point"
  },
  "properties": {
    "@id": "bar",
    "@type": "bar",
    "amenity": "bar",
    "cuisine": "bar",
    "name": "bar"
  },
  "type": "Feature",
  "id": "node/21154906"
}