Skip to content
GuidesBlogPlaygroundDashboard

Execute a PlazaQL query

$client->query->execute(string data, ?string format): FeatureCollection
POST/api/v1/query

Execute a PlazaQL query

ParametersExpand Collapse
data: string

PlazaQL query string

format?:optional string

Response format: json (default), geojson, csv, ndjson

ReturnsExpand Collapse
list<GeoJsonFeature> features

Array of GeoJSON Feature objects

Type type

Always FeatureCollection

Execute a PlazaQL query

<?php

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

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

$featureCollection = $client->query->execute(
  data: '$$ = search(node, amenity: "cafe").around(distance: 500, geometry: point(48.8566, 2.3522));',
  format: 'format',
);

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"
}