Skip to content

API Reference

PostgREST exposes the functions of the api schema as endpoints under /api/rpc/ that return JSON. All endpoints accept GET requests with query-string parameters.

Full RPC index

RPC Used by Notes
get_playground_clusters Standalone cluster tier zoom ≤ clusterMaxZoom
get_playgrounds_bbox Standalone polygon tier zoom > clusterMaxZoom
get_playground Deeplink restore single feature
get_playground_centroids Lightweight per-playground rows not used by spieli's own frontend
get_equipment PlaygroundPanel devices, pitches, benches within a bbox
get_standalone_equipment Standalone pitch layer pitches/benches outside playgrounds
get_pitch Pitch deeplink restore (#P<osm_id>) single standalone pitch
get_pois PlaygroundPanel nearby toilets, bus stops, cafés
get_trees PlaygroundPanel tree layer natural=tree nodes and natural=tree_row lines
get_meta Hub federation discovery instance metadata + import freshness
get_nearest_playgrounds Not used by the frontend since #949 ordered by distance
get_playgrounds (deprecated) Legacy fallback region-scoped, deprecated

Two-tier client contract

The standalone client renders playgrounds through two zoom-scoped layers:

Zoom Tier RPC
≤ clusterMaxZoom (default 13) cluster get_playground_clusters(z, bbox)
> clusterMaxZoom polygon get_playgrounds_bbox(bbox)

Single-feature hydration on demand:

Use case RPC
Deeplink restore at low zoom get_playground(osm_id)

A third bbox-scoped RPC, get_playground_centroids(bbox), returns one lightweight row per playground. Neither the standalone map nor the hub calls it (the hub merges cluster buckets instead, see How the hub works internally); it is there for other clients.

get_playground_clusters(z, bbox)

Pre-aggregated cluster buckets for the cluster tier. Each bucket counts playgrounds whose centroid snaps to a zoom-appropriate grid cell, broken down by mapping detail.

Parameters

Name Type Default Notes
z int — Zoom level — drives cell size via a hardcoded table (10 Mm at z=0, halving each level down to ~1.2 km at z=13)
min_lon, min_lat, max_lon, max_lat float8 — WGS84 bounding box
filter_private boolean false When true, exclude every playground that is not public: access = private, no or customers
filter_hide_private boolean false When true, exclude only private playgrounds (access = private or no) and keep customers-only ones. Sent by the frontend's "No private ones" filter (#1002). A backend older than this parameter answers 404 PGRST202; the client then retries without it and stops sending it to that backend for the session. The filter is then not applied there at the cluster tier (bucket counts include private playgrounds, and buckets carry no access, so a bucket of one is an ordinary pin); only the polygon tier filters it client-side, and the hub's macro tier counts that backend as "can't filter"
filter_water boolean false When true, include only water playgrounds
filter_baby boolean false When true, include only baby-friendly playgrounds
filter_toddler boolean false When true, include only toddler-friendly playgrounds
filter_wheelchair boolean false When true, include only wheelchair-accessible playgrounds
filter_bench boolean false When true, include only playgrounds with a bench
filter_picnic boolean false When true, include only playgrounds with a picnic table
filter_shelter boolean false When true, include only playgrounds with a shelter
filter_table_tennis boolean false When true, include only playgrounds with a table tennis table
filter_soccer boolean false When true, include only playgrounds with a football pitch
filter_basketball boolean false When true, include only playgrounds with a basketball court
filter_fence boolean false When true, include only playgrounds with a fence — own tags, or a separate barrier=fence way along ≥ 75 % of the outline (#773)
filter_has_dogs boolean false When true, include only playgrounds where dogs are allowed
filter_theme boolean false When true, include only playgrounds with a recognised playground:theme
filter_shade boolean false When true, include only playgrounds with shade
filter_lit boolean false When true, include only playgrounds whose has_lit is true
filter_complete boolean true When false, exclude complete playgrounds
filter_partial boolean true When false, exclude partial playgrounds
filter_missing boolean true When false, exclude missing playgrounds

Response — JSON array of bucket objects:

[
  {
    "lon":         9.7140,
    "lat":         50.5489,
    "count":       2,
    "complete":    1,
    "partial":     0,
    "missing":     1
  }
]

Invariant: count = complete + partial + missing for every bucket. Every playground — including access-restricted ones — is counted into its completeness bucket; there is no separate restricted field. The filter_private parameter still excludes access-restricted playgrounds from the result when set.

Bucket centre: emitted lon / lat is the unweighted spatial mean of the bucket's member centroids (ST_Centroid(ST_Collect(centroid_3857)), reprojected to WGS84) — not the grid anchor. The grid still defines which playgrounds share a bucket (the grouping key), but the dot is drawn at the geographic mean of those members so it tracks settlements rather than a lattice. Output is deterministic for a given (z, bbox) and dataset: identical inputs produce identical positions. See Frontend Guide — Cluster buckets for the grouping-vs-position split.

Example

curl 'https://example.com/api/rpc/get_playground_clusters?z=12&min_lon=9&min_lat=50&max_lon=10&max_lat=51'

get_playgrounds_bbox(bbox)

Polygon-tier RPC. Returns the same FeatureCollection shape as the legacy region-scoped get_playgrounds(relation_id), but restricted to playgrounds whose geometry intersects the bbox (so polygons straddling the viewport edge are returned in full).

Parameters

Name Type Notes
min_lon, min_lat, max_lon, max_lat float8 WGS84 bounding box

Response — GeoJSON FeatureCollection. Each feature's properties include osm_id, osm_type (R, W, or N), name, leisure, operator, access, surface, area, the playground-stats counts (device_count, bench_count, shelter_count, picnic_count, table_tennis_count, and tree_count — natural=tree nodes within 15 m of the playground on the ground), and the per-equipment booleans (is_water, for_baby, for_toddler, for_wheelchair, has_soccer, has_basketball, has_fence, has_dogs, has_theme, has_shade, has_lit), plus the tri-state wheelchair_play ('yes' | 'no' | null). The original tag hstore is spread on top so any OSM tag is reachable. Node playgrounds (osm_type = 'N') are returned as small circular polygons (5 m radius buffer around the node point).

The equipment booleans are aggregated across all equipment within the playground polygon. for_baby is true when any equipment has baby=yes, capacity:baby set, or playground ∈ baby_swing, basketswing, sandpit; for_toddler when any equipment has provided_for:toddler=yes or playground ∈ springy, basketswing (#1075). With no separately mapped device, the same keys on the area (playground:<device>=yes) count (#1074). See Import Pipeline — filter flags for the full trigger list.

for_wheelchair is the boolean projection of wheelchair_play, which is derived from play devices only — the playground area's own wheelchair tag is not an input, and street furniture and pitches cannot set it. wheelchair_play = 'no' means accessibility was surveyed and nothing qualified; null means nobody recorded it either way. The tri-state is carried by the per-feature RPCs only, not by the cluster, centroid or meta aggregates.

Note: the polygon RPC names the water flag is_water (legacy from the materialised-view column). The centroid RPC's filter_attrs payload (below) renames it to has_water for consistency with the other client-side filter keys (for_baby, has_soccer, …). Same boolean, different key.

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": { "type": "Polygon", "coordinates": [...] },
      "properties": {
        "osm_id":             37808214,
        "osm_type":           "W",
        "name":               "Grezzbachpark",
        "leisure":            "playground",
        "operator":           "...",
        "access":             "yes",
        "surface":            "...",
        "area":               2480,
        "tree_count":         12,
        "bench_count":        4,
        "has_soccer":         true,
        "has_fence":          true,
        "has_dogs":           false,
        "has_theme":          false,
        "has_shade":          true,  // true | false | null (untagged)
        "has_lit":            null,  // true | false | null (untagged)
        "is_water":           true,
        "for_wheelchair":     false,
        "wheelchair_play":    null   // 'yes' | 'no' | null (never surveyed)
      }
    }
  ]
}

get_playground(osm_id)

Single-feature lookup used by the deeplink-hydration path when the polygon source isn't populated for the current viewport (cluster tier on first load).

Parameters

Name Type Notes
osm_id bigint Magnitude only; the function tries both relation (-osm_id) and way (+osm_id) rows and prefers a relation row when both exist

Response — A single GeoJSON Feature with the same properties shape as one element of get_playgrounds_bbox.features[*], or JSON null when no playground matches.

Frontend convention: callers throw on non-2xx responses and treat a null body as a legitimate "not found", so server errors and missing playgrounds can be acted on differently.

get_playground_centroids(bbox)

Returns lightweight per-playground rows for a bbox — osm_id, lon/lat, completeness, and a nested filter_attrs object (has_water, for_baby, for_toddler, for_wheelchair, has_soccer, has_basketball, access_restricted). No polygon geometry, no tag hstore.

[
  {
    "osm_id":       37808214,
    "lon":          9.7096,
    "lat":          50.5438,
    "completeness": "complete",
    "filter_attrs": {
      "has_water":         true,
      "for_baby":          false,
      "for_toddler":       false,
      "for_wheelchair":    false,
      "has_soccer":        true,
      "has_basketball":    false,
      "has_fence":         true,
      "has_dogs":          false,
      "has_theme":         false,
      "has_shade":         true,  // true | false | null (untagged)
      "has_lit":           null,  // true | false | null (untagged)
      "access_restricted": false
    }
  }
]

spieli's own frontend does not call it: the server-bucketed cluster tier covers zoom ≤ 13 in both modes, and the hub merges those buckets across backends. fetchPlaygroundCentroids() in app/src/lib/api.js exists but is unused.

Note: the filter_attrs object includes has_fence, has_dogs, has_theme, has_shade and has_lit for the playground filters. has_shade and has_lit are nullable — has_shade is true when shade=yes, false when shade=no; has_lit is true for a recognised lighting value (yes, 24/7, automatic, limited, interval, times), false for no / disused; each is null when untagged (has_lit also when the value is not recognised).

Deprecated: get_playgrounds(relation_id)

The pre-tiered region-scoped RPC, deprecated since v0.3.0. It stays as the fallback a client or hub uses when a backend answers a tier RPC with 404, and for external consumers. Marked DEPRECATED via SQL COMMENT; the client fetchPlaygrounds logs a one-time console warning. No release for its removal is set.

Migration: replace any caller with fetchPlaygroundsBbox(extent, baseUrl) driven by viewport extent.

get_equipment(bbox)

Returns all playground equipment within a WGS84 bounding box — devices (playground=*), pitches (leisure=pitch), benches (amenity=bench), shelters (amenity=shelter), fitness stations (leisure=fitness_station), and picnic tables (leisure=picnic_table).

Covers nodes, polygon ways, and linear ways. Used by PlaygroundPanel to populate the equipment list and overlay layers when a playground is selected.

Parameters

Name Type Notes
min_lon, min_lat, max_lon, max_lat float8 WGS84 bbox — typically the selected playground's extent

Response — GeoJSON FeatureCollection. Each feature's properties include osm_id, osm_type (N or W), name, amenity, leisure, sport, surface, plus all OSM tags from the hstore column spread onto the properties object.

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": { "type": "Point", "coordinates": [9.71, 50.54] },
      "properties": {
        "osm_id":    12345678,
        "osm_type":  "N",
        "amenity":   null,
        "leisure":   null,
        "sport":     null,
        "playground": "slide",
        "height":    "1.2"
      }
    }
  ]
}

Example

curl 'https://example.com/api/rpc/get_equipment?min_lon=9.70&min_lat=50.53&max_lon=9.72&max_lat=50.55'

get_standalone_equipment(bbox)

Returns pitches, benches, shelters, picnic tables, and fitness stations that do not lie within any leisure=playground polygon. Used by the standalone pitch layer (filterStore.standalonePitches).

Same parameter and response shape as get_equipment. Returns an empty FeatureCollection when apiBaseUrl is empty (Overpass fallback, used in local frontend dev without a database).

Each feature's properties carry osm_id, osm_type, name, amenity, leisure, sport, surface, access, operator, plus every other OSM tag of the object merged in (lit, panoramax, hoops, reservation, fee, opening_hours, wheelchair, …). access and operator were added for the pitch panel (#934) — they are osm2pgsql columns, so the merged tags never contained them.

Example

curl 'https://example.com/api/rpc/get_standalone_equipment?min_lon=9.60&min_lat=50.50&max_lon=9.80&max_lat=50.60'

get_pitch(osm_id)

Single standalone pitch, used to restore a #P<osm_id> pitch link when the pitch layer has not loaded it yet (#934).

Parameters

Name Type Notes
osm_id bigint Magnitude only; a polygon (way or relation) is preferred over a node with the same number

Response — A single GeoJSON Feature with the same properties shape as a pitch in get_standalone_equipment, or JSON null when there is no such pitch or it lies inside a playground (the same rule the pitch layer applies, so a link resolves exactly the pitches the layer shows).

Example

curl 'https://example.com/api/rpc/get_pitch?osm_id=923521639'

get_pois(lat, lon, radius_m)

Returns nearby points of interest within radius_m metres of the given WGS84 point. Used by PlaygroundPanel to show nearby amenities.

Parameters

Name Type Default Notes
lat float8 — WGS84 latitude
lon float8 — WGS84 longitude
radius_m integer 500 Search radius in ground metres, capped at 20 000 (the frontend sends POI_RADIUS_M, default 5000). Polygon POIs count when their centroid — the position returned — is in range. Before #954 it was compared in EPSG:3857 units, which made the effective radius radius_m × cos(latitude) — about 3.2 km for 5000 in central Germany

POI types returned:

Category OSM tag
Toilets amenity=toilets
Ice cream amenity=ice_cream or amenity=cafe/restaurant + cuisine=*ice_cream*
Emergency emergency=yes + hospital/clinic, or healthcare:speciality=emergency
Bus stop highway=bus_stop
Pharmacy shop=chemist
Supermarket / convenience / bakery shop=supermarket, shop=convenience, shop=bakery

Response — JSON array:

[
  {
    "osm_id":  987654321,
    "lat":     50.5421,
    "lon":     9.7133,
    "name":    "Spielplatz-WC",
    "amenity": "toilets",
    "shop":    null,
    "highway": null,
    "tags":    {}
  }
]

Example

curl 'https://example.com/api/rpc/get_pois?lat=50.54&lon=9.71&radius_m=300'

get_trees(bbox)

Returns natural=tree nodes and natural=tree_row line features within a WGS84 bounding box. Used by PlaygroundPanel to populate the tree overlay layer when a playground is selected. Tree rows render as dark green lines on the map; the panel merges both signals into a single shade hint ("N trees / M m").

Parameters

Name Type Notes
min_lon, min_lat, max_lon, max_lat float8 WGS84 bbox

Response — GeoJSON FeatureCollection. Point features (natural=tree) carry properties.osm_id, properties.name, plus OSM tags. LineString features (natural=tree_row) additionally carry properties.length_m (row length in metres, from ST_Length).

Example

curl 'https://example.com/api/rpc/get_trees?min_lon=9.70&min_lat=50.53&max_lon=9.72&max_lat=50.55'

get_meta()

Returns instance metadata used by the Hub for federation discovery. Required for a backend to participate in a Hub.

Parameters: none (uses the configured OSM_RELATION_ID)

Response:

{
  "relation_id":          62700,
  "name":                 "Landkreis Fulda",
  "playground_count":     147,
  "complete":             42,
  "partial":              81,
  "missing":              24,
  "bbox":                 [9.43, 50.36, 10.08, 50.81],
  "last_import_at":       "2026-04-30T03:12:00Z",
  "data_age_seconds":     86400,
  "osm_data_timestamp":   "2026-04-29T21:00:00Z",
  "osm_data_age_seconds": 108000,
  "importing":            false,
  "version":              "0.4.1",
  "impressum_url":        "https://spieli.example.com/impressum",
  "privacy_url":          "https://spieli.example.com/datenschutz"
}

Field notes:

Field Notes
playground_count Total playgrounds in the region. Equals complete + partial + missing.
complete, partial, missing Completeness breakdown (access-restricted playgrounds roll into these counts, same as get_playground_clusters).
bbox [west, south, east, north] in WGS84. null when the relation is not found.
last_import_at When import.sh last ran successfully. null before any import.
data_age_seconds Seconds since last_import_at. null when last_import_at is null.
osm_data_timestamp PBF replication timestamp (when Geofabrik last generated the extract). null when the PBF header lacks this field.
osm_data_age_seconds Seconds since osm_data_timestamp. null when osm_data_timestamp is null.
importing true while osm2pgsql is actively running (data partially rebuilt); false at all other times. false on older backends that pre-date this field. The Hub drawer shows an "updating" badge while this is true.
version spieli version string baked in at import time from package.json (e.g. "0.4.1"). Displayed in the Hub's instance drawer.
impressum_url Absolute URL of the Impressum page. IMPRESSUM_URL env var takes priority; otherwise constructed from SITE_URL + /impressum. null when neither is configured. Baked in when api.sql is applied — re-apply it after changing legal env vars (see Configure the instance → Applying legal changes).
privacy_url Absolute URL of the Datenschutzerklärung. PRIVACY_URL env var takes priority; otherwise SITE_URL + /datenschutz. null when neither is configured.
has_legal true when the backend stores generated legal text in api.legal_content (written by a full import when IMPRESSUM_NAME and IMPRESSUM_ADDRESS are set). Lets the hub show the legal links via get_legal even when both URLs are null.
region_geom GeoJSON geometry | null. Simplified boundary of the region (ST_SimplifyPreserveTopology at 0.05°, WGS84), used by the hub to detect a region lying entirely inside another (@turf/boolean-contains, checked both ways, in the browser). Regions that only partly overlap get no warning. null when the relation has no polygon; omitted by pre-0.4.13 backends, which then get no overlap warning.

The hub reads the import timestamps and importing through its own /federation-status.json (written every 60 seconds by the hub's cron poll, see Monitoring); counts, bbox and region_geom come from each browser's direct get_meta call.

Example

curl 'https://example.com/api/rpc/get_meta'

get_legal(type)

Returns the legal HTML a data-node stored during its last full import. The Hub calls this when get_meta() returns a null impressum_url or privacy_url.

Parameters

Name Type Values
type text 'impressum' or 'datenschutz'

Response — JSON object or null:

{ "content": "<html>...</html>" }

Returns null (HTTP 200) when no content has been stored for the requested type, that is, when no full import has run with IMPRESSUM_NAME and IMPRESSUM_ADDRESS set.

Example

curl 'https://example.com/api/rpc/get_legal?type=impressum'

get_nearest_playgrounds(lat, lon)

Returns the nearest playgrounds to a WGS84 point, ordered by distance ascending. The frontend no longer calls it — the nearby list under the search field was removed (#949); it stays so hubs on older releases keep working.

Parameters

Name Type Default Notes
lat float8 — WGS84 latitude
lon float8 — WGS84 longitude
relation_id bigint OSM_RELATION_ID Unused; kept for API compatibility. Like playground_stats, the search covers every playground the instance imported, not only those inside the boundary polygon
max_results int 5 Maximum results, clamped to 1–50

Response — JSON array:

[
  {
    "osm_id":     37808214,
    "osm_type":   "W",
    "name":       "Grezzbachpark",
    "lat":        50.5438,
    "lon":        9.7096,
    "distance_m": 342,
    "completeness": "partial",
    "tags":       { "name": "Grezzbachpark", "operator": "…", "access": "yes" }
  }
]

completeness (complete | partial | missing) is the server-side mapping detail from playground_stats, the same value get_playground_centroids ships. Clients should prefer it over deriving one from tags: the tags carry no equipment counts, so a tag-derived value never sees mapped devices. Backends older than this field omit it.

osm_type (N | W | R) disambiguates osm_id, which is shown as an absolute value: node, way and relation ids are separate number spaces. Each playground appears once, also when it is a multipolygon relation with several outer rings. distance_m is measured to the playground's edge (0 when the point is inside it); playgrounds mapped as a node are measured to the node.

Example

curl 'https://example.com/api/rpc/get_nearest_playgrounds?lat=50.54&lon=9.71'

See also

  • Federation — Hub-mode discovery, registry.json, federation endpoints overview.
  • Deployment modes — the DEPLOY_MODE × APP_MODE combinations.
  • importer/api.sql — authoritative SQL source for every RPC.
  • app/src/lib/api.js — all client fetchers (each with JSDoc).
  • app/src/lib/tieredOrchestrator.js — moveend-driven tier picker that calls these RPCs.