stac-api-protocol 0.2.0__tar.gz → 0.3.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.
Files changed (46) hide show
  1. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/CHANGELOG.md +9 -2
  2. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/PKG-INFO +8 -1
  3. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/README.md +7 -0
  4. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/demo/README.md +19 -11
  5. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/demo/stac_api_demo/service.py +13 -6
  6. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/demo/start.sh +7 -1
  7. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/explanation/architecture.md +6 -5
  8. stac_api_protocol-0.3.0/docs/how-to/deploy-uvicorn.md +149 -0
  9. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/how-to/index.md +1 -0
  10. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/how-to/install.md +3 -0
  11. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/index.md +7 -0
  12. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/reference/api.md +34 -7
  13. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/src/stac_api_protocol/__about__.py +1 -1
  14. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/src/stac_api_protocol/main.py +29 -10
  15. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/src/stac_api_protocol/stac_service.py +62 -16
  16. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/tests/conftest.py +16 -0
  17. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/tests/test_bbox_queries.py +4 -2
  18. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/tests/test_filter_compliance.py +27 -10
  19. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/tests/test_routes.py +29 -17
  20. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/tests/test_search_validation.py +35 -18
  21. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/tests/test_stac_service.py +15 -14
  22. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/.gitignore +0 -0
  23. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/LICENSE +0 -0
  24. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/demo/.gitignore +0 -0
  25. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/demo/download-data.sh +0 -0
  26. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/demo/examples.sh +0 -0
  27. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/demo/pyproject.toml +0 -0
  28. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/demo/stac_api_demo/__init__.py +0 -0
  29. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/diagrams/architecture.svg +0 -0
  30. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/diagrams/architecture_dark.svg +0 -0
  31. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/diagrams/src/architecture.puml +0 -0
  32. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/explanation/index.md +0 -0
  33. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/how-to/register-service.md +0 -0
  34. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/how-to/use-cli.md +0 -0
  35. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/reference/index.md +0 -0
  36. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/reference/openapi.html +0 -0
  37. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/tutorials/first-steps.md +0 -0
  38. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/docs/tutorials/index.md +0 -0
  39. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/pyproject.toml +0 -0
  40. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/src/stac_api_protocol/__init__.py +0 -0
  41. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/src/stac_api_protocol/models.py +0 -0
  42. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/src/stac_api_protocol/plugin_loader.py +0 -0
  43. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/src/stac_api_protocol/py.typed +0 -0
  44. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/src/stac_api_protocol/queryables.json +0 -0
  45. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/tests/test_models.py +0 -0
  46. {stac_api_protocol-0.2.0 → stac_api_protocol-0.3.0}/tests/test_plugin_loader.py +0 -0
@@ -23,6 +23,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
23
23
 
24
24
  ## [Unreleased]
25
25
 
26
+ ## [0.3.0] - 2026-11-30
27
+
28
+ ### Changed
29
+
30
+ - **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.
31
+
26
32
  ## [0.2.0] - 2026-11-25
27
33
 
28
34
  ### Changed
@@ -31,7 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
31
37
 
32
38
  ### Added
33
39
 
34
- - **Breaking:** Added [STAC API - Filter Extension Specification](https://github.com/stac-api-extensions/filter) support.
40
+ - **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
41
 
36
42
  ## [0.1.1] - 2026-11-14
37
43
 
@@ -53,7 +59,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
53
59
 
54
60
  - Initial project release.
55
61
 
56
- [Unreleased]: https://github.com/Terradue/stac-api-protocol/compare/0.2.0...HEAD
62
+ [Unreleased]: https://github.com/Terradue/stac-api-protocol/compare/0.3.0...HEAD
63
+ [0.3.0]: https://github.com/Terradue/stac-api-protocol/compare/0.2.0...0.3.0
57
64
  [0.2.0]: https://github.com/Terradue/stac-api-protocol/compare/0.1.1...0.2.0
58
65
  [0.1.1]: https://github.com/Terradue/stac-api-protocol/compare/0.1.0...0.1.1
59
66
  [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.2.0
3
+ Version: 0.3.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
- cd demo
12
- uv venv
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` runs Uvicorn directly
21
- and forwards all arguments to it.
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 launch outside the repository.
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,27 @@ 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. It does not add a CQL
48
- endpoint; `pygeofilter-duckdb` translates the existing search arguments internally.
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.
@@ -145,20 +145,24 @@ class GeoParquetService(StacApiService):
145
145
  )
146
146
  }
147
147
 
148
- def get_collections(self) -> Collections:
148
+ def get_collections(self, base_url: str) -> Collections:
149
149
  """Return all static collection descriptions, including metadata-only datasets."""
150
150
  return Collections(
151
151
  collections=[collection.clone() for collection in self._collections.values()],
152
- links=[Link("self", "/collections"), Link("root", "/")],
152
+ links=[
153
+ Link("self", f"{base_url}/collections"),
154
+ Link("root", f"{base_url}/"),
155
+ ],
153
156
  )
154
157
 
155
- def describe_collection(self, collection_id: str) -> Collection | None:
158
+ def describe_collection(self, base_url: str, collection_id: str) -> Collection | None:
156
159
  """Return an independent collection description, or None for an unknown ID."""
157
160
  collection = self._collections.get(collection_id)
158
161
  return collection.clone() if collection is not None else None
159
162
 
160
163
  def get_features(
161
164
  self,
165
+ base_url: str,
162
166
  collection_id: str,
163
167
  limit: int | None,
164
168
  bbox: list[float] | None,
@@ -172,15 +176,18 @@ class GeoParquetService(StacApiService):
172
176
  """
173
177
  if collection_id not in self._collections:
174
178
  return None
175
- return self.get_item_search(bbox, None, datetime, limit, None, [collection_id], filter)
179
+ return self.get_item_search(
180
+ base_url, bbox, None, datetime, limit, None, [collection_id], filter
181
+ )
176
182
 
177
- def get_feature(self, collection_id: str, feature_id: str) -> Item | None:
183
+ def get_feature(self, base_url: str, collection_id: str, feature_id: str) -> Item | None:
178
184
  """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])
185
+ result = self.get_item_search(base_url, None, None, None, 1, [feature_id], [collection_id])
180
186
  return next(iter(result), None)
181
187
 
182
188
  def get_item_search(
183
189
  self,
190
+ base_url: str,
184
191
  bbox: list[float] | None,
185
192
  intersects: GeometryGeoJSON | GeometryCollection | None,
186
193
  datetime: str | None,
@@ -16,4 +16,10 @@
16
16
 
17
17
  set -euo pipefail
18
18
 
19
- exec uv run --no-project uvicorn stac_api_protocol.main:app --host 0.0.0.0 --port 8090
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 "$@"
@@ -29,11 +29,12 @@ between the HTTP adapter and an adopter's catalogue application. It is an abstra
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 receives a FastAPI `Request` to derive public
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 four bundled STAC API
36
- classes, which each adopter must implement.
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. Apart from the shared landing-page method, service methods receive ordinary
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,149 @@
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`, and the queryables `$id`
136
+ should be `https://api.example.com/stac/queryables`. Inspect provider-generated
137
+ navigation links too. Open the public `/stac/docs` URL in a browser and check that
138
+ its schema loads.
139
+
140
+ | Symptom | What to check |
141
+ | --- | --- |
142
+ | Links use `http` for public HTTPS | The ingress sends `X-Forwarded-Proto: https` and Uvicorn trusts the connecting proxy. |
143
+ | Links contain an internal hostname or port | The received `Host` contains the public authority. `X-Forwarded-Host` alone is insufficient. |
144
+ | Links omit `/stac` | Set `--root-path /stac` for the externally mounted application. |
145
+ | Prefixed requests return 404 | The ingress strips the prefix and forwards to the correct backend route. |
146
+ | Landing links are correct but provider links are wrong | The provider uses the supplied `base_url` for navigation links. |
147
+
148
+ A successful localhost check alone does not validate public ingress headers or
149
+ 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.
@@ -56,3 +56,6 @@ path remains `stac_api_protocol.main:app`.
56
56
 
57
57
  There is no `stac_api_protocol` command-line entry point. Run the application
58
58
  through an ASGI server.
59
+
60
+ For production hosting, reverse proxies, or Knative, follow
61
+ [Deploy with Uvicorn](deploy-uvicorn.md).
@@ -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
 
@@ -22,27 +22,54 @@ methods with parsed filter values. All seven operations belong to the same
22
22
  registered `item_service` provider.
23
23
 
24
24
  The constructor requires `id`, `title`, and `description`. Five catalogue operations
25
- are abstract. `get_landing_page(request)` and `get_conformance_declaration()` are
26
- final concrete methods and must not be overridden. The landing page derives its
27
- links from the request URL without query parameters. Both responses advertise the
28
- four bundled STAC API classes: Core, Item Search, Collections, and OGC API Features.
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(request)` | `LandingPage` |
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` | Served by the HTTP adapter | JSON Schema (`application/schema+json`) |
42
+ | `GET /collections/{collectionId}/queryables` | Adapter checks `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
+
46
73
  ## Filter and result semantics
47
74
 
48
75
  - `bbox` is a list of numbers or `None`; `ids` and `collections` are lists of strings
@@ -14,4 +14,4 @@
14
14
 
15
15
  """Package metadata for STAC API Protocol."""
16
16
 
17
- __version__ = "0.2.0"
17
+ __version__ = "0.3.0"
@@ -68,6 +68,10 @@ app = FastAPI(
68
68
  )
69
69
 
70
70
 
71
+ def _get_url(request: Request) -> str:
72
+ return str(request.base_url).rstrip("/")
73
+
74
+
71
75
  @app.exception_handler(StarletteHTTPException)
72
76
  async def http_exception_handler(_request: Request, error: StarletteHTTPException) -> JSONResponse:
73
77
  """Return application and framework HTTP errors using the STAC error schema."""
@@ -173,10 +177,12 @@ def _validate_datetime(datetime_value: str | None) -> None:
173
177
  responses={"4XX": {"model": StacException}, "5XX": {"model": StacException}},
174
178
  tags=["Core"],
175
179
  )
176
- def get_landing_page(service: StacApiService = Depends(get_item_service)) -> Response:
180
+ def get_landing_page(
181
+ request: Request, service: StacApiService = Depends(get_item_service)
182
+ ) -> Response:
177
183
  """Return the configured service catalogue landing page."""
178
184
  try:
179
- landing_page: LandingPage = service.get_landing_page()
185
+ landing_page: LandingPage = service.get_landing_page(_get_url(request))
180
186
  except Exception as e:
181
187
  raise _server_error(f"An error occurred when looking for the Landing Page: {e}") from e
182
188
 
@@ -207,10 +213,12 @@ def _collection_with_queryables(collection: Collection) -> Collection:
207
213
  responses={"4XX": {"model": StacException}, "5XX": {"model": StacException}},
208
214
  tags=["Collections"],
209
215
  )
210
- def get_collections(service: StacApiService = Depends(get_item_service)) -> Collections:
216
+ def get_collections(
217
+ request: Request, service: StacApiService = Depends(get_item_service)
218
+ ) -> Collections:
211
219
  """List collections from the configured service."""
212
220
  try:
213
- result = service.get_collections()
221
+ result = service.get_collections(_get_url(request))
214
222
  return result.model_copy(
215
223
  update={
216
224
  "collections": [_collection_with_queryables(entry) for entry in result.collections]
@@ -228,6 +236,7 @@ def get_collections(service: StacApiService = Depends(get_item_service)) -> Coll
228
236
  tags=["Collections"],
229
237
  )
230
238
  def describe_collection(
239
+ request: Request,
231
240
  collection_id: str = Path(..., alias="collectionId"),
232
241
  service: StacApiService = Depends(get_item_service),
233
242
  ) -> Response:
@@ -235,7 +244,7 @@ def describe_collection(
235
244
  collection: Collection | None = None
236
245
 
237
246
  try:
238
- collection = service.describe_collection(collection_id)
247
+ collection = service.describe_collection(_get_url(request), collection_id)
239
248
  except Exception as e:
240
249
  raise _server_error(
241
250
  f"An error occurred when looking for Collection {collection_id}: {e}"
@@ -306,6 +315,7 @@ def _get_filter(
306
315
  tags=["Features"],
307
316
  )
308
317
  def get_features(
318
+ request: Request,
309
319
  collection_id: str = Path(..., alias="collectionId"),
310
320
  limit: Annotated[int | None, Query(ge=1, le=10000)] = 10,
311
321
  bbox: Annotated[
@@ -327,7 +337,9 @@ def get_features(
327
337
  search_result: ItemCollection | None = None
328
338
 
329
339
  try:
330
- search_result = service.get_features(collection_id, limit, bbox, datetime, expression)
340
+ search_result = service.get_features(
341
+ _get_url(request), collection_id, limit, bbox, datetime, expression
342
+ )
331
343
  except Exception as e:
332
344
  raise _server_error(
333
345
  f"An error occurred when getting Features from Collection {collection_id} with criteria: limit={limit}, bbox={bbox}, datetime={datetime}: {e}"
@@ -347,6 +359,7 @@ def get_features(
347
359
  tags=["Features"],
348
360
  )
349
361
  def get_feature(
362
+ request: Request,
350
363
  collection_id: str = Path(..., alias="collectionId"),
351
364
  feature_id: str = Path(..., alias="featureId"),
352
365
  service: StacApiService = Depends(get_item_service),
@@ -355,7 +368,7 @@ def get_feature(
355
368
  feature: Item | None = None
356
369
 
357
370
  try:
358
- feature = service.get_feature(collection_id, feature_id)
371
+ feature = service.get_feature(_get_url(request), collection_id, feature_id)
359
372
  except Exception as e:
360
373
  raise _server_error(
361
374
  f"An error occurred when looking for Item {feature_id} from Collection {collection_id}: {e}"
@@ -388,6 +401,7 @@ def get_conformance_declaration(
388
401
 
389
402
 
390
403
  def _item_search(
404
+ request: Request,
391
405
  bbox: list[float] | None,
392
406
  intersects: GeometryGeoJSON | GeometryCollection | None,
393
407
  datetime: str | None,
@@ -404,7 +418,7 @@ def _item_search(
404
418
 
405
419
  try:
406
420
  search_result = service.get_item_search(
407
- bbox, intersects, datetime, limit, ids, collections, filter
421
+ _get_url(request), bbox, intersects, datetime, limit, ids, collections, filter
408
422
  )
409
423
  except Exception as e:
410
424
  raise _server_error(
@@ -456,7 +470,7 @@ def get_collection_queryables(
456
470
  status 500 if the provider cannot retrieve collection metadata.
457
471
  """
458
472
  try:
459
- collection = service.describe_collection(collection_id)
473
+ collection = service.describe_collection(_get_url(request), collection_id)
460
474
  except Exception as error:
461
475
  raise _server_error("Unable to retrieve collection metadata") from error
462
476
  if collection is None:
@@ -492,6 +506,7 @@ def _parse_intersects(value: str | None) -> GeometryGeoJSON | GeometryCollection
492
506
  tags=["Item Search"],
493
507
  )
494
508
  def get_item_search(
509
+ request: Request,
495
510
  bbox: Annotated[
496
511
  list[float] | None,
497
512
  BeforeValidator(_split_bbox_coordinates),
@@ -511,6 +526,7 @@ def get_item_search(
511
526
  ) -> Response:
512
527
  """Search STAC items using query parameters."""
513
528
  return _item_search(
529
+ request,
514
530
  bbox,
515
531
  _parse_intersects(intersects),
516
532
  datetime,
@@ -528,13 +544,16 @@ def get_item_search(
528
544
  tags=["Item Search"],
529
545
  )
530
546
  def post_item_search(
531
- body: SearchBody | None = None, service: StacApiService = Depends(get_item_service)
547
+ request: Request,
548
+ body: SearchBody | None = None,
549
+ service: StacApiService = Depends(get_item_service),
532
550
  ) -> Response:
533
551
  """Search STAC items using a validated JSON request body."""
534
552
  if not body:
535
553
  raise _not_found("No search criteria specified")
536
554
 
537
555
  return _item_search(
556
+ request,
538
557
  body.bbox,
539
558
  _parse_intersects(body.intersects) if body.intersects is not None else None,
540
559
  body.datetime,