Skip to content
GuidesPlaygroundDashboard

Fetch multiple features by type and ID

client.Elements.Batch(ctx, body) (*FeatureCollection, error)
POST/api/v1/features/batch

Fetch multiple features by type and ID

ParametersExpand Collapse
body ElementBatchParams
BatchRequest param.Field[BatchRequest]
ReturnsExpand Collapse
type FeatureCollection struct{…}

Bare GeoJSON FeatureCollection. Pagination metadata is returned in HTTP headers (X-Limit, X-Has-More, X-Next-Cursor, X-Next-Offset, Link).

Features []GeoJsonFeature
Coordinates GeoJsonGeometryCoordinatesUnion

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
type GeoJsonGeometryCoordinatesArray []float64
type GeoJsonGeometryCoordinatesArray [][]float64
type GeoJsonGeometryCoordinatesArray [][][]float64
type GeoJsonGeometryCoordinatesArray [][][][]float64
Type GeoJsonGeometryType
One of the following:
const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"
const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"
const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"
const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"
const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"
const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"
Properties map[string, unknown]
Type GeoJsonFeatureType
ID stringoptional

Feature identifier (type/osm_id)

OsmID int64optional

OpenStreetMap ID

Type FeatureCollectionType

Fetch multiple features by type and ID

package main

import (
  "context"
  "fmt"

  "github.com/plazafyi/plaza-go"
  "github.com/plazafyi/plaza-go/option"
)

func main() {
  client := githubcomplazafyiplazago.NewClient(
    option.WithAPIKey("My API Key"),
  )
  featureCollection, err := client.Elements.Batch(context.TODO(), githubcomplazafyiplazago.ElementBatchParams{
    BatchRequest: githubcomplazafyiplazago.BatchRequestParam{
      Elements: githubcomplazafyiplazago.F([]githubcomplazafyiplazago.BatchRequestElementParam{githubcomplazafyiplazago.BatchRequestElementParam{
        ID: githubcomplazafyiplazago.F(int64(0)),
        Type: githubcomplazafyiplazago.F(githubcomplazafyiplazago.BatchRequestElementsTypeNode),
      }}),
    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", featureCollection.Features)
}
Returns Examples