Skip to content

Commit 1730617

Browse files
authored
Move "Static to Dynamic best practices" to a dedicated API best practices doc (#23)
2 parents d5185fd + 265fe35 commit 1730617

2 files changed

Lines changed: 48 additions & 37 deletions

File tree

best-practices-api.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# STAC API Best Practices
2+
3+
_This page is very much a work in progress_
4+
5+
## Table of Contents
6+
7+
- [Static to Dynamic best practices](#static-to-dynamic-best-practices)
8+
- [Ingestion and links](#ingestion-and-links)
9+
- [Keep catalogs in sync with cloud notification and queue services](#keep-catalogs-in-sync-with-cloud-notification-and-queue-services)
10+
11+
*Note: This section uses the term 'Catalog' (with an uppercase C) to refer to the JSON entity specified in the
12+
[Catalog spec](https://github.com/radiantearth/stac-spec/blob/master/catalog-spec/catalog-spec.md), and 'catalog' (with a lowercase c) to refer to any full STAC implementation,
13+
which can be any mix of Catalogs, Collections, and Items.*
14+
15+
16+
## Static to Dynamic best practices
17+
18+
Many implementors are using static catalogs to be the reliable core of their dynamic services, or layering their STAC API
19+
on top of any static catalog that is published. These are some recommendations on how to handle this:
20+
21+
### Ingestion and links
22+
23+
Implementors have found that it's best to 'ingest' a static STAC into an internal datastore (often elasticsearch, but a
24+
traditional database could work fine too) and then generate the full STAC API responses from that internal representation.
25+
There are instances that have the API refer directly to the static STAC Items, but this only works well if the static STAC
26+
catalog is an 'absolute published catalog'. So the recommendation is to always use absolute links - either in the static
27+
published catalog, or to create new absolute links for the STAC search/ endpoint
28+
responses, with the API's location at the base url. The `/` endpoint with the catalog could either link directly
29+
to the static catalog, or can follow the 'dynamic catalog layout' recommendations above with a new set of URL's.
30+
31+
Ideally each Item would use its `links` to provide a reference back to the static location. The location of the static
32+
Item should be treated as the canonical location, as the generated API is more likely to move or be temporarily down. The
33+
spec provides the `derived_from` rel field, which fits well enough, but `canonical` is likely the more appropriate one
34+
as everything but the links should be the same.
35+
36+
### Keep catalogs in sync with cloud notification and queue services
37+
38+
There is a set of emerging practices to use services like Amazon's Simple Queue Service (SQS)
39+
and Simple Notification Service (SNS) to keep catalogs in sync.
40+
There is a great [blog post](https://aws.amazon.com/blogs/publicsector/keeping-a-spatiotemporal-asset-catalog-stac-up-to-date-with-sns-sqs/)
41+
on the CBERS STAC implementation on AWS.
42+
The core idea is that a static catalog should emit a notification whenever it changes. The recommendation for SNS is to use the STAC
43+
Item JSON as the message body, with some fields such as a scene’s datetime and geographic bounding box that allows
44+
basic geographic filtering from listeners.
45+
46+
The dynamic STAC API would then listen to the notifications and update its internal datastore whenever new data comes into
47+
the static catalog. Implementors have had success using AWS Lambda to do a full 'serverless' updating of the elasticsearch
48+
database, but it could just as easily be a server-based process.

best-practices-catalog-and-collection.md

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
- [Derived from relation (`derived_from`)](#derived-from-relation-derived_from)
1919
- [Versioning for Catalogs](#versioning-for-catalogs)
2020
- [Example](#example)
21-
- [Static to Dynamic best practices](#static-to-dynamic-best-practices)
22-
- [Ingestion and links](#ingestion-and-links)
23-
- [Keep catalogs in sync with cloud notification and queue services](#keep-catalogs-in-sync-with-cloud-notification-and-queue-services)
2421

2522
*Note: This section uses the term 'Catalog' (with an uppercase C) to refer to the JSON entity specified in the
2623
[Catalog spec](https://github.com/radiantearth/stac-spec/blob/master/catalog-spec/catalog-spec.md), and 'catalog' (with a lowercase c) to refer to any full STAC implementation,
@@ -310,37 +307,3 @@ This ensures that `my_item_02.json` includes a link to `my_item_01.json`
310307
- `root / collections / example_collection / items / my_item / my_item.json`
311308
- `root / collections / example_collection / items / my_item / my_item_01.json`
312309
- `root / collections / example_collection / items / my_item / my_item_02.json`
313-
314-
## Static to Dynamic best practices
315-
316-
Many implementors are using static catalogs to be the reliable core of their dynamic services, or layering their STAC API
317-
on top of any static catalog that is published. These are some recommendations on how to handle this:
318-
319-
### Ingestion and links
320-
321-
Implementors have found that it's best to 'ingest' a static STAC into an internal datastore (often elasticsearch, but a
322-
traditional database could work fine too) and then generate the full STAC API responses from that internal representation.
323-
There are instances that have the API refer directly to the static STAC Items, but this only works well if the static STAC
324-
catalog is an 'absolute published catalog'. So the recommendation is to always use absolute links - either in the static
325-
published catalog, or to create new absolute links for the STAC search/ endpoint
326-
responses, with the API's location at the base url. The `/` endpoint with the catalog could either link directly
327-
to the static catalog, or can follow the 'dynamic catalog layout' recommendations above with a new set of URL's.
328-
329-
Ideally each Item would use its `links` to provide a reference back to the static location. The location of the static
330-
Item should be treated as the canonical location, as the generated API is more likely to move or be temporarily down. The
331-
spec provides the `derived_from` rel field, which fits well enough, but `canonical` is likely the more appropriate one
332-
as everything but the links should be the same.
333-
334-
### Keep catalogs in sync with cloud notification and queue services
335-
336-
There is a set of emerging practices to use services like Amazon's Simple Queue Service (SQS)
337-
and Simple Notification Service (SNS) to keep catalogs in sync.
338-
There is a great [blog post](https://aws.amazon.com/blogs/publicsector/keeping-a-spatiotemporal-asset-catalog-stac-up-to-date-with-sns-sqs/)
339-
on the CBERS STAC implementation on AWS.
340-
The core idea is that a static catalog should emit a notification whenever it changes. The recommendation for SNS is to use the STAC
341-
Item JSON as the message body, with some fields such as a scene’s datetime and geographic bounding box that allows
342-
basic geographic filtering from listeners.
343-
344-
The dynamic STAC API would then listen to the notifications and update its internal datastore whenever new data comes into
345-
the static catalog. Implementors have had success using AWS Lambda to do a full 'serverless' updating of the elasticsearch
346-
database, but it could just as easily be a server-based process.

0 commit comments

Comments
 (0)