Skip to content

Commit fc94fd1

Browse files
jonhealy1m-mohr
andauthored
Document filtering by type for children endpoint (#8)
* Generalize /children endpoints to be usable outside of landing page #3, general rewrite/update #2 * Document filtering by type for children endpoint This PR proposes adding an optional `type` query parameter to the `/children` endpoint to support filtering results by resource type (e.g., `Catalog` or `Collection`). ### Motivation While the specification recommends separating different types into different hierarchy branches as a best practice, real-world data organization often results in "mixed content" folders (e.g., a Project Catalog containing both sub-project Catalogs and direct Dataset Collections). In dynamic, database-backed APIs (like those using Elasticsearch), retrieving and paginating mixed-type lists can be computationally expensive and complex to implement. Adding a standard `type` parameter allows: 1. **Backend Optimization:** Implementations can execute efficient, type-specific queries (e.g., `type: "Catalog"`) rather than fetching all children and filtering in memory. 2. **Client Flexibility:** Clients can request only the resource type they are interested in (e.g., "Show me sub-folders" vs. "Show me datasets") without receiving unwanted data. 3. **Standardization:** Prevents the proliferation of custom filter parameters (e.g., `?kind=`, `?filter=`) across different implementations. ### Proposed Change Add a section detailing the `type` parameter: #### Filtering by Type Implementations MAY support a `type` query parameter to allow clients to request a specific resource type. * `GET .../children?type=Catalog` * `GET .../children?type=Collection` * Update README.md Co-authored-by: Matthias Mohr <[email protected]> * Add conformance class for type filtering Co-authored-by: Matthias Mohr <[email protected]> * Update README.md * Fix Markdown header for Filtering by Type section Updated the section header for 'Filtering by Type' to use proper Markdown formatting. * Add 'type' query parameter to getChildren operation Added 'type' query parameter to filter catalogs or collections. * Fix syntax * Refactor parameters section in openapi.yaml Formatted parameters section for consistency. * Fix indentation in openapi.yaml parameters section * Update README.md Co-authored-by: Matthias Mohr <[email protected]> * Fix typos and remove redundant links in README --------- Co-authored-by: Matthias Mohr <[email protected]>
1 parent 7f64c85 commit fc94fd1

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- [Link Relations](#link-relations)
55
- [Endpoints](#endpoints)
66
- [Pagination](#pagination)
7+
- [Filtering by Type](#filtering-by-type)
78
- [Example](#example)
89

910
## Overview
@@ -26,7 +27,7 @@ it often also implements the [Browsable Extension](https://github.com/stac-api-e
2627
The drawback of static catalogs is, that catalogs have to be traversed and a lot of requests for the
2728
children have to be executed.
2829

29-
This STAC API extension specifies an endpoint that returns a list of all Catalog and Collection
30+
This STAC API extension specifies an endpoint that returns a list of all Catalogs and Collections
3031
that are referenced from a Catalog or Collection with the relation type `child`.
3132
For this, it contains a link with relation type `children` which points to an endpoint `/children`.
3233
The `/children` endpoint returns *all* the Catalog and Collection objects referenced by these
@@ -37,7 +38,7 @@ the *immediate* children of a Catalog or Collection in an efficient way, similar
3738
While the `child` link relation already allows for describing these relationships,
3839
this scheme requires a client to retrieve each resource URL to find any information about
3940
the children (e.g., title, description), which can cause significant performance issues in user-facing
40-
applications. Implementers may choose to to return only a subset of fields for each Catalog or Collection,
41+
applications. Implementers may choose to return only a subset of fields for each Catalog or Collection,
4142
but the objects must still be valid Catalogs and Collections.
4243

4344
## Link Relations
@@ -90,6 +91,21 @@ the STAC API - Collections and Features Specification, section
9091
To the greatest extent possible, the hierarchy should be structured such that all children can be
9192
retrieved from the endpoint in a single call without pagination.
9293

94+
## Filtering by Type
95+
96+
This section describes an OPTIONAL conformance class that adds a `type` query parameter for filtering:
97+
98+
- **Conformance Class:** <https://api.stacspec.org/v1.0.0-rc.2/children#type-filter>
99+
100+
Because the `children` array is polymorphic (containing both `Catalog` and `Collection` objects),
101+
implementations MAY support a `type` query parameter to allow clients to filter the response to a specific resource type.
102+
Results SHALL be *filtered*, a conversion between Catalog and Collection is not foreseen.
103+
104+
- `GET .../children?type=Catalog` - Returns only child Catalogs.
105+
- `GET .../children?type=Collection` - Returns only child Collections.
106+
107+
This is recommended for implementations where backend storage (e.g., Elasticsearch indices) or client logic benefits from strict typing.
108+
93109
## Example
94110

95111
Below is a minimal example, but captures the essence.
@@ -102,7 +118,7 @@ Please note the `child` and `children` link relations:
102118
"stac_version": "1.1.0",
103119
"id": "example-stac",
104120
"title": "A simple STAC API Example, implementing STAC API - Children",
105-
"description": "This Catalog aims to demonstrate the a simple landing page",
121+
"description": "This Catalog aims to demonstrate a simple landing page",
106122
"type": "Catalog",
107123
"conformsTo": [
108124
"https://api.stacspec.org/v1.0.0/core",

openapi.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ paths:
4646
conformsTo:
4747
- 'https://api.stacspec.org/v1.0.0/core'
4848
- 'https://api.stacspec.org/v1.0.0-rc.2/children'
49+
- 'https://api.stacspec.org/v1.0.0-rc.2/children#type-filter'
4950
- 'http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/core'
5051
- 'http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30'
5152
- 'http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson'
@@ -78,6 +79,14 @@ paths:
7879
description: |-
7980
A body of Catalogs and Collections that are immediate children of this root Catalog.
8081
operationId: getChildren
82+
parameters:
83+
- name: type
84+
in: query
85+
description: Filters the response to only include Catalogs or Collections.
86+
required: false
87+
schema:
88+
type: string
89+
enum: [Catalog, Collection]
8190
responses:
8291
'200':
8392
$ref: '#/components/responses/Children'

0 commit comments

Comments
 (0)