Skip to content

Streaming & Response Formats

Endpoints that return a list of features take a format parameter:

ValueContent-TypeDeliveryDescription
json (default)application/geo+jsonSent in one pieceGeoJSON FeatureCollection.
geojsonapplication/geo+jsonStreamed in chunksSame FeatureCollection, sent as it is produced.
csvtext/csvStreamed in chunksHeader row, then one row per feature with id, type, lat, lng and properties. properties is a JSON-encoded cell.
ndjsonapplication/x-ndjsonStreamed in chunksOne GeoJSON Feature per line.

json and geojson have the same shape. The difference is delivery: json waits until the response is complete, while geojson, csv and ndjson start arriving immediately. An unknown value returns a 422 validation_error.

These endpoints accept format:

EndpointNotes
/featuresAll four formats.
/searchAll four formats.
/queryApplies to feature results. See below.
/isochroneOnly when time or contours_meters has more than one value. A single budget always returns one Feature.
/optimizeApplies to a solved result. An asynchronous job response (status: processing) is always JSON.
/geocode, /geocode/reverse, /geocode/autocompleteAll four formats.
/elevationOnly for MultiPoint lookups. A Point lookup returns one Feature.
/routeOnly when alternatives is greater than 0. Without alternatives the route is one Feature.
/datasets/{id}/featuresAll four formats, one page at a time. The streamed formats send the next cursor in the X-Next-Cursor header only. See pagination.

A PlazaQL result is not always a FeatureCollection, and the shape follows the query:

  • Feature results, such as search(...), honor format.
  • A single computed feature, such as route(...) or isochrone(...), returns one GeoJSON Feature.
  • .count(), .sum(), .avg(), .min(), .max() and .group_by(...) return a small JSON object such as { "value": 12 } or { "groups": {...}, "total": 3 }.
  • matrix(...) returns the same object as /matrix.
  • map_match(...) returns the same FeatureCollection as /map-match, with its matchings array.

A query with several named outputs returns { "outputs": { "name": ... } }, one value per output, each shaped as above. It only supports format=json. Any other format is a 400.

format has no effect on single features, counts, aggregates or matrices, because they aren’t lists of features. See response shapes for the full table.

/matrix, /map-match and /nearest have no format parameter.

  • Queries returning 1,000+ features
  • Exporting data for offline processing
  • Showing results incrementally in a UI
  • Memory-constrained environments

For small result sets, just parse the response normally with the default json format. For large ones, ask for geojson, csv or ndjson so the response streams.

Plaza responses are standard HTTP — use any streaming parser that works with chunked transfer encoding. Here’s what we recommend for each language and format.

Browser (GeoJSON) — use oboe.js. It pattern-matches nodes inside a streaming JSON response, so you get each feature the moment it’s fully parsed:

import oboe from "oboe";
oboe({
url: "https://plaza.fyi/api/v1/features?within=-74.01,40.70,-73.97,40.75&tags[amenity]=cafe&format=geojson",
headers: { "x-api-key": process.env.PLAZA_API_KEY },
})
.node("features.*", (feature) => {
console.log(feature.properties.name);
return oboe.drop; // free memory after processing each feature
})
.done(() => console.log("done"))
.fail((err) => console.error("stream error:", err));

Node.js (GeoJSON) — use jsonstream-next. Compose it with the fetch response body using stream.compose and async-iterate:

import { compose } from "node:stream";
import JSONStream from "jsonstream-next";
const response = await fetch(
"https://plaza.fyi/api/v1/features?within=-74.01,40.70,-73.97,40.75&tags[amenity]=cafe&format=geojson",
{ headers: { "x-api-key": process.env.PLAZA_API_KEY } },
);
for await (const feature of compose(response.body, JSONStream.parse("features.*"))) {
console.log(feature.properties.name);
}

CSV (Node.js) — use csv-parser. Same pattern:

import { compose } from "node:stream";
import csvParser from "csv-parser";
const response = await fetch(
"https://plaza.fyi/api/v1/features?within=-74.01,40.70,-73.97,40.75&tags[amenity]=cafe&format=csv",
{ headers: { "x-api-key": process.env.PLAZA_API_KEY } },
);
for await (const row of compose(response.body, csvParser())) {
console.log(row.name);
}

NDJSON (Node.js) — each line is a complete Feature, so you can split on newlines and parse as you go:

import readline from "node:readline";
import { Readable } from "node:stream";
const response = await fetch(
"https://plaza.fyi/api/v1/features?within=-74.01,40.70,-73.97,40.75&tags[amenity]=cafe&format=ndjson",
{ headers: { "x-api-key": process.env.PLAZA_API_KEY } },
);
const lines = readline.createInterface({ input: Readable.fromWeb(response.body) });
for await (const line of lines) {
console.log(JSON.parse(line).properties.name);
}

GeoJSON — use ijson. It yields objects matching a prefix path as they’re parsed from the stream:

import httpx
import ijson
with httpx.stream(
"GET",
"https://plaza.fyi/api/v1/features",
params={"within": "-74.01,40.70,-73.97,40.75", "tags[amenity]": "cafe", "format": "geojson"},
headers={"x-api-key": "your-key"},
) as response:
for feature in ijson.items(response.stream, "features.item"):
print(feature["properties"]["name"])

CSV — the standard library handles this. Wrap the streaming response in csv.DictReader:

import csv
import httpx
with httpx.stream(
"GET",
"https://plaza.fyi/api/v1/features",
params={"within": "-74.01,40.70,-73.97,40.75", "tags[amenity]": "cafe", "format": "csv"},
headers={"x-api-key": "your-key"},
) as response:
reader = csv.DictReader(response.iter_lines())
for row in reader:
print(row["name"])

NDJSON — no extra library. Parse each line as it arrives:

import json
import httpx
with httpx.stream(
"GET",
"https://plaza.fyi/api/v1/features",
params={"within": "-74.01,40.70,-73.97,40.75", "tags[amenity]": "cafe", "format": "ndjson"},
headers={"x-api-key": "your-key"},
) as response:
for line in response.iter_lines():
print(json.loads(line)["properties"]["name"])

GeoJSON — Go’s standard library already streams JSON. json.NewDecoder reads from an io.Reader and decodes tokens incrementally — no extra dependency needed:

decoder := json.NewDecoder(resp.Body)
// Skip to the features array
for {
t, err := decoder.Token()
if err != nil {
log.Fatal(err)
}
if t == "features" {
decoder.Token() // opening bracket
break
}
}
// Decode each Feature as it arrives
for decoder.More() {
var feature geojson.Feature
if err := decoder.Decode(&feature); err != nil {
log.Fatal(err)
}
fmt.Println(feature.Properties["name"])
}

CSV — use the standard library’s encoding/csv package. It reads records one at a time from any io.Reader:

reader := csv.NewReader(resp.Body)
header, _ := reader.Read() // first row is the header
nameIdx := slices.Index(header, "name")
for {
record, err := reader.Read()
if err != nil {
break
}
fmt.Println(record[nameIdx])
}

Use --no-buffer to see results as they arrive:

Terminal window
curl --no-buffer \
-H "x-api-key: $PLAZA_API_KEY" \
"https://plaza.fyi/api/v1/features?within=-74.01,40.70,-73.97,40.75&tags[building]=yes&format=geojson"

If the connection drops mid-response, your parser will see an unexpected EOF. To handle this:

  1. Track the last osm_id you processed.
  2. Retry with a filter that excludes already-seen IDs, or use cursor-based pagination.
  3. If the same query consistently fails, add tighter spatial filters to reduce the result set.