# Query ## Execute a multi-step query pipeline `query.execute(QueryExecuteParams**kwargs) -> QueryExecuteResponse` **post** `/api/v1/query` Execute a multi-step query pipeline ### Parameters - `steps: Iterable[Step]` Ordered list of query steps to execute - `type: Literal["overpass", "sparql", "filter", "transform"]` Step type: `overpass`, `sparql`, `filter`, or `transform` - `"overpass"` - `"sparql"` - `"filter"` - `"transform"` - `query: Optional[str]` Query string for this step (required for overpass/sparql steps) ### Returns - `class QueryExecuteResponse: …` Pipeline execution result containing the output of each step. - `steps: List[Dict[str, object]]` Results from each pipeline step in execution order ### Example ```python import os from plaza import Plaza client = Plaza( api_key=os.environ.get("PLAZA_API_KEY"), # This is the default and can be omitted ) response = client.query.execute( steps=[{ "type": "overpass" }], ) print(response.steps) ``` #### Response ```json { "steps": [ { "foo": "bar" } ] } ``` ## Execute an Overpass QL query `query.overpass(QueryOverpassParams**kwargs) -> FeatureCollection` **post** `/api/v1/overpass` Execute an Overpass QL query ### Parameters - `data: str` Overpass QL query string ### Returns - `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`. - `features: List[GeoJsonFeature]` Array of GeoJSON Feature objects - `geometry: GeoJsonGeometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `coordinates: Union[List[float], List[List[float]], List[List[List[float]]], List[List[List[List[float]]]]]` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `List[float]` [longitude, latitude] or [longitude, latitude, elevation] - `List[List[float]]` Array of [lng, lat] positions - `List[List[List[float]]]` Array of linear rings / line strings - `List[List[List[List[float]]]]` Array of polygons - `type: Literal["Point", "LineString", "Polygon", 3 more]` Geometry type - `"Point"` - `"LineString"` - `"Polygon"` - `"MultiPoint"` - `"MultiLineString"` - `"MultiPolygon"` - `properties: Dict[str, object]` 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: Literal["Feature"]` Always `Feature` - `"Feature"` - `id: Optional[str]` Compound identifier in `type/osm_id` format - `type: Literal["FeatureCollection"]` Always `FeatureCollection` - `"FeatureCollection"` ### Example ```python import os from plaza import Plaza client = Plaza( api_key=os.environ.get("PLAZA_API_KEY"), # This is the default and can be omitted ) feature_collection = client.query.overpass( data="[out:json];node[amenity=cafe](around:500,48.8566,2.3522);out body;", ) print(feature_collection.features) ``` #### 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 `query.sparql(QuerySparqlParams**kwargs) -> SparqlResult` **post** `/api/v1/sparql` Execute a SPARQL query ### Parameters - `query: str` SPARQL query string ### Returns - `class SparqlResult: …` 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: List[Result]` 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: GeoJsonGeometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `coordinates: Union[List[float], List[List[float]], List[List[List[float]]], List[List[List[List[float]]]]]` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `List[float]` [longitude, latitude] or [longitude, latitude, elevation] - `List[List[float]]` Array of [lng, lat] positions - `List[List[List[float]]]` Array of linear rings / line strings - `List[List[List[List[float]]]]` Array of polygons - `type: Literal["Point", "LineString", "Polygon", 3 more]` Geometry type - `"Point"` - `"LineString"` - `"Polygon"` - `"MultiPoint"` - `"MultiLineString"` - `"MultiPolygon"` - `properties: Dict[str, object]` OSM tags as key-value pairs, optionally with `@type` and `@id` metadata - `type: Literal["Feature"]` Always `Feature` - `"Feature"` - `id: Optional[str]` Compound identifier in `type/osm_id` format (present when element type is known) ### Example ```python import os from plaza import Plaza client = Plaza( api_key=os.environ.get("PLAZA_API_KEY"), # This is the default and can be omitted ) sparql_result = client.query.sparql( query="SELECT ?s ?name WHERE { ?s osm:name ?name . ?s osm:amenity \"cafe\" } LIMIT 10", ) print(sparql_result.results) ``` #### Response ```json { "results": [ { "geometry": { "coordinates": [ 2.3522, 48.8566 ], "type": "Point" }, "properties": { "foo": "bar" }, "type": "Feature", "id": "id" } ] } ``` ## Domain Types ### Overpass Query - `class OverpassQuery: …` Overpass QL query request. The query is executed against Plaza's OSM database and results are returned as GeoJSON. - `data: str` Overpass QL query string ### Sparql Query - `class SparqlQuery: …` SPARQL query request. Queries OSM data using SPARQL syntax. Results are returned as a JSON object with a `results` array. - `query: str` SPARQL query string ### Sparql Result - `class SparqlResult: …` 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: List[Result]` 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: GeoJsonGeometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `coordinates: Union[List[float], List[List[float]], List[List[List[float]]], List[List[List[List[float]]]]]` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `List[float]` [longitude, latitude] or [longitude, latitude, elevation] - `List[List[float]]` Array of [lng, lat] positions - `List[List[List[float]]]` Array of linear rings / line strings - `List[List[List[List[float]]]]` Array of polygons - `type: Literal["Point", "LineString", "Polygon", 3 more]` Geometry type - `"Point"` - `"LineString"` - `"Polygon"` - `"MultiPoint"` - `"MultiLineString"` - `"MultiPolygon"` - `properties: Dict[str, object]` OSM tags as key-value pairs, optionally with `@type` and `@id` metadata - `type: Literal["Feature"]` Always `Feature` - `"Feature"` - `id: Optional[str]` Compound identifier in `type/osm_id` format (present when element type is known)