stac-api-protocol 0.2.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/CHANGELOG.md +16 -2
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/PKG-INFO +8 -1
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/README.md +7 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/demo/README.md +24 -11
- stac_api_protocol-0.4.0/demo/stac_api_demo/queryables.json +9 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/demo/stac_api_demo/service.py +25 -6
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/demo/start.sh +7 -1
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/explanation/architecture.md +7 -6
- stac_api_protocol-0.4.0/docs/how-to/deploy-uvicorn.md +150 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/how-to/index.md +1 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/how-to/install.md +3 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/how-to/register-service.md +3 -3
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/index.md +7 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/reference/api.md +63 -9
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/reference/index.md +1 -1
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/tutorials/first-steps.md +40 -8
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/__about__.py +1 -1
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/main.py +42 -19
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/queryables.json +8 -1
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/stac_service.py +77 -16
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/tests/conftest.py +16 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/tests/test_bbox_queries.py +4 -2
- stac_api_protocol-0.4.0/tests/test_demo_service.py +38 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/tests/test_filter_compliance.py +57 -21
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/tests/test_routes.py +29 -17
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/tests/test_search_validation.py +35 -18
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/tests/test_stac_service.py +19 -14
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/.gitignore +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/LICENSE +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/demo/.gitignore +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/demo/download-data.sh +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/demo/examples.sh +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/demo/pyproject.toml +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/demo/stac_api_demo/__init__.py +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/diagrams/architecture.svg +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/diagrams/architecture_dark.svg +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/diagrams/src/architecture.puml +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/explanation/index.md +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/how-to/use-cli.md +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/reference/openapi.html +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/docs/tutorials/index.md +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/pyproject.toml +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/__init__.py +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/models.py +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/plugin_loader.py +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/src/stac_api_protocol/py.typed +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/tests/test_models.py +0 -0
- {stac_api_protocol-0.2.0 → stac_api_protocol-0.4.0}/tests/test_plugin_loader.py +0 -0
|
@@ -23,6 +23,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
23
23
|
|
|
24
24
|
## [Unreleased]
|
|
25
25
|
|
|
26
|
+
## [0.4.0] - 2026-12-01
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- Queryables JSON Schema definition delegated to `StacApiService` implementations.
|
|
31
|
+
|
|
32
|
+
## [0.3.0] - 2026-11-30
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- **Breaking:** `StacApiService.get_landing_page`, `get_collections`, `describe_collection`, `get_features`, `get_feature`, and `get_item_search` now require `base_url: str` as the first argument after `self`. Providers must update their method signatures and forward this argument in internal calls; direct callers must supply it. The HTTP adapter passes the request base URL, including any deployment prefix and with trailing slashes removed. Direct callers must also omit trailing slashes. Landing-page links are absolute again.
|
|
37
|
+
|
|
26
38
|
## [0.2.0] - 2026-11-25
|
|
27
39
|
|
|
28
40
|
### Changed
|
|
@@ -31,7 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
31
43
|
|
|
32
44
|
### Added
|
|
33
45
|
|
|
34
|
-
- **Breaking:** Added [STAC API - Filter Extension Specification](https://github.com/stac-api-extensions/filter)
|
|
46
|
+
- **Breaking:** Added protocol-level support for the [STAC API - Filter Extension Specification v1.0.0-rc.4](https://github.com/stac-api-extensions/filter/blob/v1.0.0-rc.4/README.md), including CQL2 Text and CQL2 JSON request handling, queryables endpoints, and conformance declarations. Service providers must accept the new `filter` argument in `get_features` and `get_item_search` and implement filter evaluation.
|
|
35
47
|
|
|
36
48
|
## [0.1.1] - 2026-11-14
|
|
37
49
|
|
|
@@ -53,7 +65,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
53
65
|
|
|
54
66
|
- Initial project release.
|
|
55
67
|
|
|
56
|
-
[Unreleased]: https://github.com/Terradue/stac-api-protocol/compare/0.
|
|
68
|
+
[Unreleased]: https://github.com/Terradue/stac-api-protocol/compare/0.3.1...HEAD
|
|
69
|
+
[0.3.1]: https://github.com/Terradue/stac-api-protocol/compare/0.3.0...0.3.1
|
|
70
|
+
[0.3.0]: https://github.com/Terradue/stac-api-protocol/compare/0.2.0...0.3.0
|
|
57
71
|
[0.2.0]: https://github.com/Terradue/stac-api-protocol/compare/0.1.1...0.2.0
|
|
58
72
|
[0.1.1]: https://github.com/Terradue/stac-api-protocol/compare/0.1.0...0.1.1
|
|
59
73
|
[0.1.0]: https://github.com/Terradue/stac-api-protocol/releases/tag/0.1.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: stac-api-protocol
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: A Python FastAPI HTTP adapter for STAC API Core, Item Search, Features and Collections.
|
|
5
5
|
Project-URL: Documentation, https://terradue.github.io/stac-api-protocol/
|
|
6
6
|
Project-URL: Issues, https://github.com/Terradue/stac-api-protocol/issues
|
|
@@ -54,6 +54,13 @@ limitations under the License.
|
|
|
54
54
|
|
|
55
55
|
A Python FastAPI HTTP adapter for STAC API Core, Item Search, Features and Collections.
|
|
56
56
|
|
|
57
|
+
**Since version 0.2.0, the protocol implementation supports the
|
|
58
|
+
[STAC API - Filter Extension Specification v1.0.0-rc.4](https://github.com/stac-api-extensions/filter/blob/v1.0.0-rc.4/README.md).**
|
|
59
|
+
This includes CQL2 Text and CQL2 JSON request handling, queryables discovery, and
|
|
60
|
+
Filter conformance declarations. Evaluating filters against catalogue data remains
|
|
61
|
+
the service provider's responsibility. See the
|
|
62
|
+
[Filter Extension service contract](docs/reference/api.md#filter-extension-support-since-020).
|
|
63
|
+
|
|
57
64
|
## Project conventions
|
|
58
65
|
|
|
59
66
|
This project is templated a Hatch-based Python package with:
|
|
@@ -23,6 +23,13 @@ limitations under the License.
|
|
|
23
23
|
|
|
24
24
|
A Python FastAPI HTTP adapter for STAC API Core, Item Search, Features and Collections.
|
|
25
25
|
|
|
26
|
+
**Since version 0.2.0, the protocol implementation supports the
|
|
27
|
+
[STAC API - Filter Extension Specification v1.0.0-rc.4](https://github.com/stac-api-extensions/filter/blob/v1.0.0-rc.4/README.md).**
|
|
28
|
+
This includes CQL2 Text and CQL2 JSON request handling, queryables discovery, and
|
|
29
|
+
Filter conformance declarations. Evaluating filters against catalogue data remains
|
|
30
|
+
the service provider's responsibility. See the
|
|
31
|
+
[Filter Extension service contract](docs/reference/api.md#filter-extension-support-since-020).
|
|
32
|
+
|
|
26
33
|
## Project conventions
|
|
27
34
|
|
|
28
35
|
This project is templated a Hatch-based Python package with:
|
|
@@ -8,19 +8,17 @@ Collection metadata comes from `collections.json`; item queries use DuckDB and
|
|
|
8
8
|
From the repository root, with Python 3.11 or newer:
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
uv pip install -e .. -e .
|
|
14
|
-
|
|
15
|
-
bash ./download-data.sh
|
|
16
|
-
bash ./start.sh
|
|
11
|
+
bash demo/download-data.sh
|
|
12
|
+
bash demo/start.sh
|
|
17
13
|
```
|
|
18
14
|
|
|
19
15
|
The demo has its own `pyproject.toml`, which registers the service plugin and
|
|
20
|
-
declares Uvicorn and database dependencies. `demo/start.sh`
|
|
21
|
-
and
|
|
16
|
+
declares Uvicorn and database dependencies. `demo/start.sh` creates `demo/.venv`
|
|
17
|
+
if needed, installs both the local adapter and demo packages into it, and runs
|
|
18
|
+
Uvicorn with that environment's Python. It works from any working directory and
|
|
19
|
+
forwards all arguments to Uvicorn, for example `bash demo/start.sh --port 8000`.
|
|
22
20
|
Install it in an environment with no other `stacapi.service:item_service` provider.
|
|
23
|
-
Set `STAC_DEMO_DATA_DIR` to an absolute directory to
|
|
21
|
+
Set `STAC_DEMO_DATA_DIR` to an absolute directory to use a different data location.
|
|
24
22
|
The download script also honors this variable. Downloads are excluded from Git.
|
|
25
23
|
|
|
26
24
|
In another terminal, with `curl` and `jq` installed:
|
|
@@ -34,17 +32,32 @@ The script makes one request per API operation, including both GET and POST
|
|
|
34
32
|
search, using an actual NAIP tile and spatial/temporal bounds from the dataset.
|
|
35
33
|
Swagger documentation is available at `/docs`.
|
|
36
34
|
|
|
35
|
+
Since version 0.2.0, the protocol supports the
|
|
36
|
+
[STAC API - Filter Extension Specification v1.0.0-rc.4](https://github.com/stac-api-extensions/filter/blob/v1.0.0-rc.4/README.md).
|
|
37
|
+
The script's GET and POST `/search` examples send CQL2 JSON filters and require a
|
|
38
|
+
provider that evaluates them. This demo provider rejects CQL2 filters; its supported
|
|
39
|
+
search constraints are listed below. Protocol support does not add filter
|
|
40
|
+
evaluation to the demo backend.
|
|
41
|
+
|
|
37
42
|
All five collection descriptions are exposed. Only NAIP items are loaded;
|
|
38
43
|
other listed collections have empty item results. Unknown collections and missing
|
|
39
44
|
individual items return 404. Searches support IDs, collections, bbox, intersects,
|
|
40
45
|
and inclusive datetime instants/intervals (including open bounds). Results are
|
|
41
46
|
sorted by collection and ID, default to 10 items, and have no pagination.
|
|
42
47
|
Six-coordinate boxes use XY only because NAIP footprints have no elevation.
|
|
48
|
+
The service methods accept the request-derived `base_url`, without a trailing slash, as their first argument
|
|
49
|
+
and forward it when delegating to item search. Collection-list navigation links
|
|
50
|
+
use this URL, including any deployment prefix, as do the inherited landing-page links.
|
|
43
51
|
The original asset and item links are preserved and may point to Planetary Computer.
|
|
44
52
|
|
|
45
53
|
GET `bbox` accepts comma-separated coordinates or repeated query parameters.
|
|
46
54
|
Other GET lists use repeated query parameters, and POST `intersects` is a
|
|
47
|
-
JSON-encoded string.
|
|
48
|
-
|
|
55
|
+
JSON-encoded string. `pygeofilter-duckdb` translates the existing search arguments
|
|
56
|
+
internally.
|
|
49
57
|
Each query uses its own DuckDB connection. Runtime queries use downloaded local
|
|
50
58
|
files and a preinstalled spatial extension, with no external database server.
|
|
59
|
+
|
|
60
|
+
Since v0.4.0, `GeoParquetService.get_queryables()` supplies the document served at
|
|
61
|
+
both queryables endpoints from `stac_api_demo/queryables.json`. It advertises no
|
|
62
|
+
CQL2 fields (`properties: {}`, `additionalProperties: false`) because this demo
|
|
63
|
+
rejects CQL2 filters. The adapter preserves the provider's `$id` and other metadata.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2019-09/schema",
|
|
3
|
+
"$id": "/queryables",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"title": "NAIP demo queryables",
|
|
6
|
+
"description": "This demo supports standard Item Search parameters but does not implement CQL2 filtering.",
|
|
7
|
+
"properties": {},
|
|
8
|
+
"additionalProperties": false
|
|
9
|
+
}
|
|
@@ -20,6 +20,7 @@ import json
|
|
|
20
20
|
import os
|
|
21
21
|
from datetime import datetime as DateTime
|
|
22
22
|
from functools import cache
|
|
23
|
+
from importlib.resources import files
|
|
23
24
|
from pathlib import Path
|
|
24
25
|
from typing import TYPE_CHECKING
|
|
25
26
|
|
|
@@ -145,20 +146,35 @@ class GeoParquetService(StacApiService):
|
|
|
145
146
|
)
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
def
|
|
149
|
+
def get_queryables(self) -> dict[str, object]:
|
|
150
|
+
"""Return a fresh schema advertising no CQL2 fields in this demo.
|
|
151
|
+
|
|
152
|
+
The demo supports standard Item Search parameters but rejects CQL2
|
|
153
|
+
expressions. The schema therefore disallows additional queryables.
|
|
154
|
+
"""
|
|
155
|
+
schema: dict[str, object] = json.loads(
|
|
156
|
+
files("stac_api_demo").joinpath("queryables.json").read_text("utf-8")
|
|
157
|
+
)
|
|
158
|
+
return schema
|
|
159
|
+
|
|
160
|
+
def get_collections(self, base_url: str) -> Collections:
|
|
149
161
|
"""Return all static collection descriptions, including metadata-only datasets."""
|
|
150
162
|
return Collections(
|
|
151
163
|
collections=[collection.clone() for collection in self._collections.values()],
|
|
152
|
-
links=[
|
|
164
|
+
links=[
|
|
165
|
+
Link("self", f"{base_url}/collections"),
|
|
166
|
+
Link("root", f"{base_url}/"),
|
|
167
|
+
],
|
|
153
168
|
)
|
|
154
169
|
|
|
155
|
-
def describe_collection(self, collection_id: str) -> Collection | None:
|
|
170
|
+
def describe_collection(self, base_url: str, collection_id: str) -> Collection | None:
|
|
156
171
|
"""Return an independent collection description, or None for an unknown ID."""
|
|
157
172
|
collection = self._collections.get(collection_id)
|
|
158
173
|
return collection.clone() if collection is not None else None
|
|
159
174
|
|
|
160
175
|
def get_features(
|
|
161
176
|
self,
|
|
177
|
+
base_url: str,
|
|
162
178
|
collection_id: str,
|
|
163
179
|
limit: int | None,
|
|
164
180
|
bbox: list[float] | None,
|
|
@@ -172,15 +188,18 @@ class GeoParquetService(StacApiService):
|
|
|
172
188
|
"""
|
|
173
189
|
if collection_id not in self._collections:
|
|
174
190
|
return None
|
|
175
|
-
return self.get_item_search(
|
|
191
|
+
return self.get_item_search(
|
|
192
|
+
base_url, bbox, None, datetime, limit, None, [collection_id], filter
|
|
193
|
+
)
|
|
176
194
|
|
|
177
|
-
def get_feature(self, collection_id: str, feature_id: str) -> Item | None:
|
|
195
|
+
def get_feature(self, base_url: str, collection_id: str, feature_id: str) -> Item | None:
|
|
178
196
|
"""Look up an item by both collection and item ID, returning None if absent."""
|
|
179
|
-
result = self.get_item_search(None, None, None, 1, [feature_id], [collection_id])
|
|
197
|
+
result = self.get_item_search(base_url, None, None, None, 1, [feature_id], [collection_id])
|
|
180
198
|
return next(iter(result), None)
|
|
181
199
|
|
|
182
200
|
def get_item_search(
|
|
183
201
|
self,
|
|
202
|
+
base_url: str,
|
|
184
203
|
bbox: list[float] | None,
|
|
185
204
|
intersects: GeometryGeoJSON | GeometryCollection | None,
|
|
186
205
|
datetime: str | None,
|
|
@@ -16,4 +16,10 @@
|
|
|
16
16
|
|
|
17
17
|
set -euo pipefail
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
|
|
20
|
+
if [[ ! -x .venv/bin/python ]]; then
|
|
21
|
+
uv venv .venv
|
|
22
|
+
fi
|
|
23
|
+
uv pip install --python .venv/bin/python -e .. -e .
|
|
24
|
+
exec .venv/bin/python -m uvicorn stac_api_protocol.main:app \
|
|
25
|
+
--host 0.0.0.0 --port 8090 "$@"
|
|
@@ -25,15 +25,16 @@ acts exclusively as the HTTP adapter**.
|
|
|
25
25
|
## The service port
|
|
26
26
|
|
|
27
27
|
`StacApiService`, defined in `src/stac_api_protocol/stac_service.py`, is the boundary
|
|
28
|
-
between the HTTP adapter and an adopter's catalogue application. It is an abstract base class with
|
|
28
|
+
between the HTTP adapter and an adopter's catalogue application. It is an abstract base class with six adopter-defined catalogue operations and
|
|
29
29
|
two final metadata methods. Adopters subclass it and supply a catalogue identifier,
|
|
30
30
|
title, and description. Incomplete subclasses cannot be instantiated.
|
|
31
31
|
|
|
32
|
-
The shared landing-page method
|
|
33
|
-
links. This is an HTTP coupling in the current service contract; catalogue search
|
|
32
|
+
The shared landing-page method builds root-relative links. Catalogue search
|
|
34
33
|
and retrieval operations remain independent of FastAPI request objects. The
|
|
35
|
-
conformance method returns a fixed declaration of the
|
|
36
|
-
classes,
|
|
34
|
+
conformance method returns a fixed declaration of the bundled STAC and OGC
|
|
35
|
+
classes, including Filter Extension capabilities since version 0.2.0. The adapter
|
|
36
|
+
handles the Filter protocol; each adopter must implement the advertised filtering
|
|
37
|
+
semantics. See the [service contract](../reference/api.md#filter-extension-support-since-020).
|
|
37
38
|
|
|
38
39
|
```text
|
|
39
40
|
HTTP client
|
|
@@ -67,7 +68,7 @@ implementation at runtime through an installed Python entry point.
|
|
|
67
68
|
| Provider factory | Construct or obtain a configured service and supply it to the HTTP adapter. |
|
|
68
69
|
|
|
69
70
|
Keep FastAPI responses and dependency injection out of your catalogue business
|
|
70
|
-
logic.
|
|
71
|
+
logic. Service methods receive ordinary
|
|
71
72
|
filter values and return the
|
|
72
73
|
STAC objects specified by the port. If your domain uses different objects, map
|
|
73
74
|
them to these types at the service boundary. The port intentionally uses PySTAC,
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Copyright 2026 Terradue
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
-->
|
|
16
|
+
|
|
17
|
+
# Deploy with Uvicorn
|
|
18
|
+
|
|
19
|
+
Run `stac-api-protocol` as `stac_api_protocol.main:app`. Install Uvicorn and
|
|
20
|
+
exactly one registered service provider in the same Python environment, following
|
|
21
|
+
[Install and run](install.md) and [Register a service factory](register-service.md).
|
|
22
|
+
Discovery happens at import time; missing or duplicate registrations stop startup.
|
|
23
|
+
The exported `app` is an application instance, so do not pass `--factory`.
|
|
24
|
+
|
|
25
|
+
## Start the server
|
|
26
|
+
|
|
27
|
+
For direct local access:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
python -m uvicorn stac_api_protocol.main:app \
|
|
31
|
+
--host 127.0.0.1 --port 8000 --no-proxy-headers
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
For containers, bind to `0.0.0.0` so traffic can reach the container port.
|
|
35
|
+
Use your container platform or process supervisor for restarts and shutdown.
|
|
36
|
+
Reserve `--reload` for development. Size worker counts according to the provider's
|
|
37
|
+
memory and backend connection requirements: each worker loads its own application.
|
|
38
|
+
|
|
39
|
+
## Preserve public URLs behind a reverse proxy
|
|
40
|
+
|
|
41
|
+
The adapter obtains the catalogue root from
|
|
42
|
+
`str(request.base_url).rstrip("/")`. It uses this value for landing-page links
|
|
43
|
+
and passes it as `base_url` to provider catalogue operations. Queryables responses
|
|
44
|
+
also derive their `$id` from the request URL. Correct public URLs therefore depend
|
|
45
|
+
on the deployment's proxy configuration.
|
|
46
|
+
|
|
47
|
+
For a TLS-terminating proxy at `10.0.0.5`, for example:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
python -m uvicorn stac_api_protocol.main:app \
|
|
51
|
+
--host 0.0.0.0 --port 8000 \
|
|
52
|
+
--proxy-headers --forwarded-allow-ips=10.0.0.5
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Replace the example address with the proxy address seen by Uvicorn. Restrict
|
|
56
|
+
backend access to that proxy. Configure it to preserve the public `Host`, including
|
|
57
|
+
any non-default port, and set `X-Forwarded-Proto: https` for public HTTPS traffic.
|
|
58
|
+
The trusted proxy must replace untrusted client-supplied forwarding headers.
|
|
59
|
+
|
|
60
|
+
`--proxy-headers` enables forwarded scheme and client-address handling;
|
|
61
|
+
`--forwarded-allow-ips` selects trusted peers. Avoid `*` unless only trusted proxies
|
|
62
|
+
can connect. See the [Uvicorn HTTP settings](https://uvicorn.dev/settings/#http).
|
|
63
|
+
|
|
64
|
+
Uvicorn's [proxy-header middleware](https://github.com/Kludex/uvicorn/blob/main/uvicorn/middleware/proxy_headers.py)
|
|
65
|
+
does not restore the hostname from `X-Forwarded-Host`. If an ingress rewrites
|
|
66
|
+
`Host` to an internal routing hostname, request-derived links use that hostname.
|
|
67
|
+
Adding trusted IPs cannot fix this; arrange for the public `Host` to reach the app.
|
|
68
|
+
|
|
69
|
+
The adapter has no built-in public-base-URL environment variable.
|
|
70
|
+
`ASF_GATEWAY_PUBLIC_URL`, used by a separate gateway in some deployment examples,
|
|
71
|
+
is not an adapter setting and does not change `request.base_url`.
|
|
72
|
+
|
|
73
|
+
## Serve under a path prefix
|
|
74
|
+
|
|
75
|
+
For a public root of `https://api.example.com/stac`, configure the proxy to strip
|
|
76
|
+
`/stac` before forwarding, then add `--root-path /stac`:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
python -m uvicorn stac_api_protocol.main:app \
|
|
80
|
+
--host 0.0.0.0 --port 8000 \
|
|
81
|
+
--proxy-headers --forwarded-allow-ips=10.0.0.5 \
|
|
82
|
+
--root-path /stac
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
A public request for `/stac/collections` must reach the backend as `/collections`.
|
|
86
|
+
`--root-path` describes the external mount point; it does not configure proxy
|
|
87
|
+
routing or rewrite rules. Omit it when exposed at `/`. Do not rely on
|
|
88
|
+
`X-Forwarded-Prefix` to set it automatically.
|
|
89
|
+
|
|
90
|
+
With the public host and scheme preserved, `request.base_url` is
|
|
91
|
+
`https://api.example.com/stac/`, and the provider receives
|
|
92
|
+
`https://api.example.com/stac`. FastAPI also uses the root path for documentation
|
|
93
|
+
and OpenAPI access. See [FastAPI behind a proxy](https://fastapi.tiangolo.com/advanced/behind-a-proxy/).
|
|
94
|
+
|
|
95
|
+
## Run in Knative Serving
|
|
96
|
+
|
|
97
|
+
Package the adapter, Uvicorn, and your registered provider in the image. Use this
|
|
98
|
+
command in a shell entrypoint:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
exec python -m uvicorn stac_api_protocol.main:app \
|
|
102
|
+
--host 0.0.0.0 --port "${PORT:-8080}" \
|
|
103
|
+
--proxy-headers --forwarded-allow-ips=127.0.0.1
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The shell expands `PORT`; a literal `${PORT:-8080}` in an exec-form container
|
|
107
|
+
argument will not expand. Ensure the configured container port matches the listener.
|
|
108
|
+
|
|
109
|
+
Knative's [queue-proxy implementation](https://github.com/knative/serving/blob/main/pkg/queue/sharedmain/main.go)
|
|
110
|
+
forwards to the user container on `127.0.0.1` without overriding `Host`, which is
|
|
111
|
+
why this command trusts loopback. Verify the connecting address if your platform
|
|
112
|
+
changes this topology.
|
|
113
|
+
|
|
114
|
+
The public ingress must still preserve `Host` and forward the public scheme.
|
|
115
|
+
For example, an upstream Contour gateway that rewrites `Host` to a Knative routing
|
|
116
|
+
hostname can cause links to advertise that hostname. Configure public-domain
|
|
117
|
+
routing so the application receives the intended host. Loopback trust alone
|
|
118
|
+
cannot recover a rewritten hostname. Add `--root-path /stac` when an upstream
|
|
119
|
+
gateway strips that public prefix, as described above.
|
|
120
|
+
|
|
121
|
+
## Verify through the public endpoint
|
|
122
|
+
|
|
123
|
+
Run these checks against the URL clients actually use, including any prefix.
|
|
124
|
+
They require `curl` and `jq`:
|
|
125
|
+
|
|
126
|
+
```sh
|
|
127
|
+
api='https://api.example.com/stac'
|
|
128
|
+
curl -fsS "$api/" | jq -r '.links[] | [.rel, .href] | @tsv'
|
|
129
|
+
curl -fsS "$api/collections" | jq -r '.links[] | [.rel, .href] | @tsv'
|
|
130
|
+
curl -fsS "$api/queryables" | jq -r '."$id"'
|
|
131
|
+
curl -fsS "$api/openapi.json" > /dev/null
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The landing page's `self` should be `https://api.example.com/stac/`, its `data`
|
|
135
|
+
link should be `https://api.example.com/stac/collections`. Since v0.4.0, the
|
|
136
|
+
queryables `$id` is supplied by the provider and is not rewritten by the adapter;
|
|
137
|
+
check it against your provider configuration. Inspect provider-generated
|
|
138
|
+
navigation links too. Open the public `/stac/docs` URL in a browser and check that
|
|
139
|
+
its schema loads.
|
|
140
|
+
|
|
141
|
+
| Symptom | What to check |
|
|
142
|
+
| --- | --- |
|
|
143
|
+
| Links use `http` for public HTTPS | The ingress sends `X-Forwarded-Proto: https` and Uvicorn trusts the connecting proxy. |
|
|
144
|
+
| Links contain an internal hostname or port | The received `Host` contains the public authority. `X-Forwarded-Host` alone is insufficient. |
|
|
145
|
+
| Links omit `/stac` | Set `--root-path /stac` for the externally mounted application. |
|
|
146
|
+
| Prefixed requests return 404 | The ingress strips the prefix and forwards to the correct backend route. |
|
|
147
|
+
| Landing links are correct but provider links are wrong | The provider uses the supplied `base_url` for navigation links. |
|
|
148
|
+
|
|
149
|
+
A successful localhost check alone does not validate public ingress headers or
|
|
150
|
+
prefix handling.
|
|
@@ -17,4 +17,5 @@ limitations under the License.
|
|
|
17
17
|
# How-to guides
|
|
18
18
|
|
|
19
19
|
- [Install and run](install.md): prepare an environment and serve the adapter.
|
|
20
|
+
- [Deploy with Uvicorn](deploy-uvicorn.md): configure proxies, public URLs, path prefixes, and Knative.
|
|
20
21
|
- [Register a service factory](register-service.md): connect your implementation through Python entry points.
|
|
@@ -19,7 +19,7 @@ limitations under the License.
|
|
|
19
19
|
## Implement the port
|
|
20
20
|
|
|
21
21
|
Create a concrete implementation of `StacApiService` from
|
|
22
|
-
`stac_api_protocol.stac_service`. Implement the
|
|
22
|
+
`stac_api_protocol.stac_service`. Implement the six abstract methods in the
|
|
23
23
|
[service contract](../reference/api.md), using your own application and backend
|
|
24
24
|
logic. The [tutorial](../tutorials/first-steps.md) provides a complete minimal
|
|
25
25
|
example.
|
|
@@ -42,8 +42,8 @@ def create_service() -> StacApiService:
|
|
|
42
42
|
|
|
43
43
|
This example uses the base constructor, which requires catalogue identity metadata.
|
|
44
44
|
Adapt construction to your application's configuration and resource lifecycle.
|
|
45
|
-
The inherited landing-page method uses the incoming request; your
|
|
46
|
-
|
|
45
|
+
The inherited landing-page method uses the incoming request; your catalogue operations receive ordinary filter values. Since v0.4.0,
|
|
46
|
+
`get_queryables()` also supplies the provider-owned schema without request arguments.
|
|
47
47
|
|
|
48
48
|
## Declare the entry point
|
|
49
49
|
|
|
@@ -18,6 +18,13 @@ limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
**STAC API Protocol enables existing data systems to become interoperable STAC API services without requiring them to adopt a new catalogue infrastructure.**
|
|
20
20
|
|
|
21
|
+
**Since version 0.2.0, the protocol implementation supports the
|
|
22
|
+
[STAC API - Filter Extension Specification v1.0.0-rc.4](https://github.com/stac-api-extensions/filter/blob/v1.0.0-rc.4/README.md).**
|
|
23
|
+
The HTTP adapter handles CQL2 Text and CQL2 JSON requests, exposes queryables, and
|
|
24
|
+
advertises Filter conformance. Service providers implement filter evaluation
|
|
25
|
+
against their data. See the [Filter Extension service contract](reference/api.md#filter-extension-support-since-020)
|
|
26
|
+
for supported routes and provider requirements.
|
|
27
|
+
|
|
21
28
|
Built around a clean separation between the HTTP protocol layer for STAC API _Core_, _Collections_,
|
|
22
29
|
_Features_, and _Item Search_ and the underlying data services, it provides the essential STAC API functionality while leaving data access, metadata mapping, and catalogue operations to pluggable implementations.
|
|
23
30
|
|
|
@@ -18,31 +18,85 @@ limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
Adopters subclass `StacApiService`, defined in
|
|
20
20
|
`src/stac_api_protocol/stac_service.py`. The HTTP adapter invokes its synchronous
|
|
21
|
-
methods with parsed filter values. All
|
|
21
|
+
methods with parsed filter values. All eight operations belong to the same
|
|
22
22
|
registered `item_service` provider.
|
|
23
23
|
|
|
24
|
-
The constructor requires `id`, `title`, and `description`.
|
|
25
|
-
are abstract. `get_landing_page(
|
|
26
|
-
final concrete methods and must not be overridden. The landing page
|
|
27
|
-
links
|
|
28
|
-
|
|
24
|
+
The constructor requires `id`, `title`, and `description`. Six catalogue operations
|
|
25
|
+
are abstract. `get_landing_page()` and `get_conformance_declaration()` are
|
|
26
|
+
final concrete methods and must not be overridden. The landing page uses
|
|
27
|
+
root-relative links. Both responses advertise the bundled STAC and OGC
|
|
28
|
+
conformance classes, including Filter Extension capabilities since version 0.2.0.
|
|
29
29
|
|
|
30
30
|
## Operations and routes
|
|
31
31
|
|
|
32
32
|
| HTTP route | Service method | Return type |
|
|
33
33
|
| --- | --- | --- |
|
|
34
|
-
| `GET /` | `get_landing_page(
|
|
34
|
+
| `GET /` | `get_landing_page()` | `LandingPage` |
|
|
35
35
|
| `GET /collections` | `get_collections()` | `Collections` |
|
|
36
36
|
| `GET /collections/{collectionId}` | `describe_collection(collection_id)` | `pystac.Collection` or `None` |
|
|
37
|
-
| `GET /collections/{collectionId}/items` | `get_features(collection_id, limit, bbox, datetime)` | `pystac.ItemCollection` or `None` |
|
|
37
|
+
| `GET /collections/{collectionId}/items` | `get_features(collection_id, limit, bbox, datetime, filter)` | `pystac.ItemCollection` or `None` |
|
|
38
38
|
| `GET /collections/{collectionId}/items/{featureId}` | `get_feature(collection_id, feature_id)` | `pystac.Item` or `None` |
|
|
39
39
|
| `GET /conformance` | `get_conformance_declaration()` | `ConformanceClasses` |
|
|
40
|
-
| `GET /search`, `POST /search` | `get_item_search(bbox, intersects, datetime, limit, ids, collections)` | `pystac.ItemCollection` or `None` |
|
|
40
|
+
| `GET /search`, `POST /search` | `get_item_search(bbox, intersects, datetime, limit, ids, collections, filter)` | `pystac.ItemCollection` or `None` |
|
|
41
|
+
| `GET /queryables` | `get_queryables()` | JSON Schema (`application/schema+json`) |
|
|
42
|
+
| `GET /collections/{collectionId}/queryables` | `get_queryables()` after `describe_collection(collection_id)` | JSON Schema (`application/schema+json`) |
|
|
41
43
|
|
|
42
44
|
`LandingPage`, `Collections`, and `ConformanceClasses` come from
|
|
43
45
|
`stac_api_protocol.models`. Use these existing types rather than creating
|
|
44
46
|
parallel representations of the HTTP contract.
|
|
45
47
|
|
|
48
|
+
## Filter Extension support since 0.2.0
|
|
49
|
+
|
|
50
|
+
**Version 0.2.0 introduced protocol-level support for the
|
|
51
|
+
[STAC API - Filter Extension Specification v1.0.0-rc.4](https://github.com/stac-api-extensions/filter/blob/v1.0.0-rc.4/README.md).**
|
|
52
|
+
|
|
53
|
+
| Request | Filter representation | Default `filter-lang` |
|
|
54
|
+
| --- | --- | --- |
|
|
55
|
+
| `GET /search` and `GET /collections/{collectionId}/items` | `filter` query parameter containing CQL2 Text or JSON-encoded CQL2 JSON | `cql2-text` |
|
|
56
|
+
| `POST /search` | `filter` JSON body field containing a CQL2 JSON expression or a CQL2 Text string | `cql2-json` |
|
|
57
|
+
|
|
58
|
+
Use `filter-lang` to select `cql2-text` or `cql2-json`. The supported `filter-crs`
|
|
59
|
+
is `http://www.opengis.net/def/crs/OGC/1.3/CRS84`. Queryables are exposed at both
|
|
60
|
+
catalogue and collection scope, with discovery links in the landing page and
|
|
61
|
+
collection metadata. Collection queryables return HTTP 404 for an unknown collection.
|
|
62
|
+
|
|
63
|
+
The adapter validates CQL2 JSON structure and delegates the expression to the
|
|
64
|
+
provider. CQL2 Text is forwarded unchanged. Since 0.2.0, provider implementations
|
|
65
|
+
of `get_features` and `get_item_search` must accept a `filter` argument typed as
|
|
66
|
+
`str | dict[str, object] | bool | None`: text, a parsed JSON expression, a boolean
|
|
67
|
+
predicate, or no filter. These argument types require no Pydantic import.
|
|
68
|
+
|
|
69
|
+
Providers are responsible for evaluating expressions, combining them with other
|
|
70
|
+
search constraints, and fulfilling the advertised conformance classes. Protocol
|
|
71
|
+
support and protocol tests do not certify a backend's filtering behavior.
|
|
72
|
+
|
|
73
|
+
## Provider-defined queryables since v0.4.0
|
|
74
|
+
|
|
75
|
+
**Version 0.4.0 adds the abstract `get_queryables() -> dict[str, object]` method.**
|
|
76
|
+
Existing providers must implement this method before they can be instantiated.
|
|
77
|
+
The adapter no longer loads the protocol's bundled `queryables.json`.
|
|
78
|
+
|
|
79
|
+
Return a JSON-serializable JSON Schema document describing the Item fields your
|
|
80
|
+
backend supports in CQL2 expressions. Providers own `$schema`, `$id`, `type`,
|
|
81
|
+
`properties`, and `additionalProperties`. Keep the schema in your provider
|
|
82
|
+
package and load it with `importlib.resources`, as the demo does. Queryable names
|
|
83
|
+
are Item fields such as `id` or `eo:cloud_cover`; request parameters such as
|
|
84
|
+
`filter` and `filter-lang` are not queryable fields.
|
|
85
|
+
|
|
86
|
+
Both `/queryables` and `/collections/{collectionId}/queryables` return the provider's
|
|
87
|
+
document unchanged with media type `application/schema+json`. The method receives
|
|
88
|
+
no request URL or collection identifier, so it supplies a shared schema across
|
|
89
|
+
collections. The adapter does not rewrite `$id` to match either endpoint or
|
|
90
|
+
validate the returned schema. Configure the document's identifier in the provider.
|
|
91
|
+
For collection requests, the adapter first checks that the collection exists;
|
|
92
|
+
unknown collections return HTTP 404 without calling `get_queryables()`. A provider
|
|
93
|
+
failure returns HTTP 500 with a generic description.
|
|
94
|
+
|
|
95
|
+
The demo implements the method using its own packaged JSON file. Because its
|
|
96
|
+
backend rejects CQL2 expressions, it returns empty `properties` and
|
|
97
|
+
`additionalProperties: false`. This documents the demo's limitation; it does not
|
|
98
|
+
make the demo fulfill the protocol's advertised CQL2 conformance classes.
|
|
99
|
+
|
|
46
100
|
## Filter and result semantics
|
|
47
101
|
|
|
48
102
|
- `bbox` is a list of numbers or `None`; `ids` and `collections` are lists of strings
|
|
@@ -24,7 +24,7 @@ and HTTP error handling.
|
|
|
24
24
|
|
|
25
25
|
## Integration at a glance
|
|
26
26
|
|
|
27
|
-
1. Subclass `StacApiService` and implement its
|
|
27
|
+
1. Subclass `StacApiService` and implement its six abstract catalogue operations.
|
|
28
28
|
2. Expose a callable factory that returns your service implementation.
|
|
29
29
|
3. Register that factory in your package's `pyproject.toml`:
|
|
30
30
|
|