Skip to content
GuidesBlogPlaygroundDashboard

Fetch multiple features by type and ID

FeatureCollection Elements.Batch(ElementBatchParamsparameters, CancellationTokencancellationToken = default)
POST/api/v1/features/batch

Fetch multiple features by type and ID

ParametersExpand Collapse
ElementBatchParams parameters
required IReadOnlyList<Element> elements

Array of element references to fetch

required Long ID

OSM element ID

required Type Type

OSM element type

One of the following:
"node"Node
"way"Way
"relation"Relation
ReturnsExpand Collapse
class FeatureCollection:

GeoJSON FeatureCollection (RFC 7946). For paginated endpoints, metadata is returned in HTTP response headers rather than the body:

Header Description
X-Limit Requested result limit
X-Has-More true if more results exist
X-Next-Cursor Opaque cursor for next page (cursor pagination)
X-Next-Offset Numeric offset for next page (offset pagination)
Link RFC 8288 rel="next" link to the next page

Content-Type is application/geo+json.

required IReadOnlyList<GeoJsonFeature> Features

Array of GeoJSON Feature objects

required GeoJsonGeometry Geometry

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

required Coordinates Coordinates

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

One of the following:
IReadOnlyList<Double>
IReadOnlyList<IReadOnlyList<Double>>
IReadOnlyList<IReadOnlyList<IReadOnlyList<Double>>>
IReadOnlyList<IReadOnlyList<IReadOnlyList<IReadOnlyList<Double>>>>
required Type Type

Geometry type

One of the following:
"Point"Point
"LineString"LineString
"Polygon"Polygon
"MultiPoint"MultiPoint
"MultiLineString"MultiLineString
"MultiPolygon"MultiPolygon
required IReadOnlyDictionary<string, JsonElement> Properties

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.

required Type Type

Always Feature

string ID

Compound identifier in type/osm_id format

required Type Type

Always FeatureCollection

Fetch multiple features by type and ID

ElementBatchParams parameters = new()
{
    Elements =
    [
        new()
        {
            ID = 21154906,
            Type = Type.Node,
        },
        new()
        {
            ID = 4589123,
            Type = Type.Way,
        },
    ],
};

var featureCollection = await client.Elements.Batch(parameters);

Console.WriteLine(featureCollection);
{
  "features": [
    {
      "geometry": {
        "coordinates": [
          2.3522,
          48.8566
        ],
        "type": "Point"
      },
      "properties": {
        "@id": "bar",
        "@type": "bar",
        "amenity": "bar",
        "cuisine": "bar",
        "name": "bar"
      },
      "type": "Feature",
      "id": "node/21154906"
    }
  ],
  "type": "FeatureCollection"
}
Returns Examples
{
  "features": [
    {
      "geometry": {
        "coordinates": [
          2.3522,
          48.8566
        ],
        "type": "Point"
      },
      "properties": {
        "@id": "bar",
        "@type": "bar",
        "amenity": "bar",
        "cuisine": "bar",
        "name": "bar"
      },
      "type": "Feature",
      "id": "node/21154906"
    }
  ],
  "type": "FeatureCollection"
}