Skip to content
GuidesPlaygroundDashboard

Execute a SPARQL query

client.query.sparql(QuerySparqlParams { query } body, RequestOptionsoptions?): SparqlResult { features, type }
POST/api/v1/sparql

Execute a SPARQL query

ParametersExpand Collapse
body: QuerySparqlParams { query }
query: string

SPARQL query string

ReturnsExpand Collapse
SparqlResult { features, type }

GeoJSON FeatureCollection of SPARQL query results

features: Array<GeoJsonFeature { geometry, properties, type, 2 more } >

GeoJSON features from SPARQL query

geometry: GeoJsonGeometry { coordinates, type }
coordinates: Array<number> | Array<Array<number>> | Array<Array<Array<number>>> | Array<Array<Array<Array<number>>>>

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
Array<number>
Array<Array<number>>
Array<Array<Array<number>>>
Array<Array<Array<Array<number>>>>
type: "Point" | "LineString" | "Polygon" | 3 more
One of the following:
"Point"
"LineString"
"Polygon"
"MultiPoint"
"MultiLineString"
"MultiPolygon"
properties: Record<string, unknown>
type: "Feature"
id?: string

Feature identifier (type/osm_id)

osm_id?: number

OpenStreetMap ID

type: "FeatureCollection"

Execute a SPARQL query

import Plaza from '@plazafyi/sdk';

const client = new Plaza({
  apiKey: process.env['PLAZA_API_KEY'], // This is the default and can be omitted
});

const sparqlResult = await client.query.sparql({ query: 'query' });

console.log(sparqlResult.features);
Returns Examples