# Query ## Execute a multi-step query pipeline `$ plaza query execute` **post** `/api/v1/query` Execute a multi-step query pipeline ### Parameters - `--step: array of object { type, query }` Ordered list of query steps to execute ### Returns - `QueryExecuteResponse: object { steps }` Pipeline execution result containing the output of each step. - `steps: array of map[unknown]` Results from each pipeline step in execution order ### Example ```cli plaza query execute \ --api-key 'My API Key' \ --step '{type: overpass}' ``` #### Response ```json { "steps": [ { "foo": "bar" } ] } ``` ## Execute an Overpass QL query `$ plaza query overpass` **post** `/api/v1/overpass` Execute an Overpass QL query ### Parameters - `--data: string` Overpass QL query string ### Returns - `feature_collection: object { features, type }` 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`. - `features: array of GeoJsonFeature` Array of GeoJSON Feature objects - `geometry: object { coordinates, type }` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `coordinates: array of number or array of array of number or array of array of array of number or array of array of array of array of number` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `Point: array of number` [longitude, latitude] or [longitude, latitude, elevation] - `LineString or MultiPoint: array of array of number` Array of [lng, lat] positions - `Polygon or MultiLineString: array of array of array of number` Array of linear rings / line strings - `MultiPolygon: array of array of array of array of number` Array of polygons - `type: "Point" or "LineString" or "Polygon" or 3 more` Geometry type - `"Point"` - `"LineString"` - `"Polygon"` - `"MultiPoint"` - `"MultiLineString"` - `"MultiPolygon"` - `properties: map[unknown]` 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: "Feature"` Always `Feature` - `"Feature"` - `id: optional string` Compound identifier in `type/osm_id` format - `type: "FeatureCollection"` Always `FeatureCollection` - `"FeatureCollection"` ### Example ```cli plaza query overpass \ --api-key 'My API Key' \ --data '[out:json];node[amenity=cafe](around:500,48.8566,2.3522);out body;' ``` #### Response ```json { "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" } ``` ## Execute a SPARQL query `$ plaza query sparql` **post** `/api/v1/sparql` Execute a SPARQL query ### Parameters - `--query: string` SPARQL query string ### Returns - `sparql_result: object { results }` SPARQL query result. Contains a `results` array of GeoJSON Feature objects. Unlike REST feature endpoints, SPARQL results may omit `@type`, `@id`, and compound `id` fields depending on the query shape. - `results: array of object { geometry, properties, type, id }` Array of GeoJSON Features matching the SPARQL query. Features include `@type` and `@id` metadata when the source element type is known, but may contain only tags as properties for untyped results. - `geometry: object { coordinates, type }` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `coordinates: array of number or array of array of number or array of array of array of number or array of array of array of array of number` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `Point: array of number` [longitude, latitude] or [longitude, latitude, elevation] - `LineString or MultiPoint: array of array of number` Array of [lng, lat] positions - `Polygon or MultiLineString: array of array of array of number` Array of linear rings / line strings - `MultiPolygon: array of array of array of array of number` Array of polygons - `type: "Point" or "LineString" or "Polygon" or 3 more` Geometry type - `"Point"` - `"LineString"` - `"Polygon"` - `"MultiPoint"` - `"MultiLineString"` - `"MultiPolygon"` - `properties: map[unknown]` OSM tags as key-value pairs, optionally with `@type` and `@id` metadata - `type: "Feature"` Always `Feature` - `"Feature"` - `id: optional string` Compound identifier in `type/osm_id` format (present when element type is known) ### Example ```cli plaza query sparql \ --api-key 'My API Key' \ --query 'SELECT ?s ?name WHERE { ?s osm:name ?name . ?s osm:amenity "cafe" } LIMIT 10' ``` #### Response ```json { "results": [ { "geometry": { "coordinates": [ 2.3522, 48.8566 ], "type": "Point" }, "properties": { "foo": "bar" }, "type": "Feature", "id": "id" } ] } ``` ## Domain Types ### Overpass Query - `overpass_query: object { data }` Overpass QL query request. The query is executed against Plaza's OSM database and results are returned as GeoJSON. - `data: string` Overpass QL query string ### Sparql Query - `sparql_query: object { query }` SPARQL query request. Queries OSM data using SPARQL syntax. Results are returned as a JSON object with a `results` array. - `query: string` SPARQL query string ### Sparql Result - `sparql_result: object { results }` SPARQL query result. Contains a `results` array of GeoJSON Feature objects. Unlike REST feature endpoints, SPARQL results may omit `@type`, `@id`, and compound `id` fields depending on the query shape. - `results: array of object { geometry, properties, type, id }` Array of GeoJSON Features matching the SPARQL query. Features include `@type` and `@id` metadata when the source element type is known, but may contain only tags as properties for untyped results. - `geometry: object { coordinates, type }` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `coordinates: array of number or array of array of number or array of array of array of number or array of array of array of array of number` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `Point: array of number` [longitude, latitude] or [longitude, latitude, elevation] - `LineString or MultiPoint: array of array of number` Array of [lng, lat] positions - `Polygon or MultiLineString: array of array of array of number` Array of linear rings / line strings - `MultiPolygon: array of array of array of array of number` Array of polygons - `type: "Point" or "LineString" or "Polygon" or 3 more` Geometry type - `"Point"` - `"LineString"` - `"Polygon"` - `"MultiPoint"` - `"MultiLineString"` - `"MultiPolygon"` - `properties: map[unknown]` OSM tags as key-value pairs, optionally with `@type` and `@id` metadata - `type: "Feature"` Always `Feature` - `"Feature"` - `id: optional string` Compound identifier in `type/osm_id` format (present when element type is known)