Skip to content
GuidesBlogPlaygroundDashboard

Fetch multiple features by type and ID

$client->elements->batch(list<Element> elements): FeatureCollection
POST/api/v1/features/batch

Fetch multiple features by type and ID

ParametersExpand Collapse
elements: list<Element>

Array of element references to fetch

ReturnsExpand Collapse
list<GeoJsonFeature> features

Array of GeoJSON Feature objects

Type type

Always FeatureCollection

Fetch multiple features by type and ID

<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

$client = new Client(apiKey: 'My API Key', environment: 'local');

$featureCollection = $client->elements->batch(
  elements: [
    ['id' => 21154906, 'type' => 'node'], ['id' => 4589123, 'type' => 'way']
  ],
);

var_dump($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"
}