radiantearth / stac-api-spec

SpatioTemporal Asset Catalog API specification - an API to make geospatial assets openly searchable and crawlable
http://stacspec.org
Apache License 2.0
220 stars 46 forks source link

Clarify self link for POST query with body parameters #380

Closed emmanuelmathot closed 1 year ago

emmanuelmathot commented 1 year ago

In case of a query with POST method and body parameters (e.g. OGC API Feature and Item-search).

POST /search
{
    "collections": ["landsat8","sentinel"],
    "bbox": [10.415,36.066,3.779,44.213],
    "limit": 200,
    "datetime": "2017-05-05T00:00:00Z"
}

What is the recommendation for the self and next links?

Complete query:

"links": [
    {
        "rel": "self",
        "href": "https://stac-api.example.com/search",
        "type": "application/geo+json",
        "method": "POST",
        "body": {
            {
                "collections": [
                    "landsat8",
                    "sentinel"
                ],
                "bbox": [
                    10.415,
                    36.066,
                    3.779,
                    44.213
                ],
                "limit": 200,
                "datetime": "2017-05-05T00:00:00Z"
            }
        }
    },
    {
        "rel": "next",
        "href": "https://stac-api.example.com/search",
        "type": "application/geo+json",
        "method": "POST",
        "body": {
            {
                "collections": [
                    "landsat8",
                    "sentinel"
                ],
                "bbox": [
                    10.415,
                    36.066,
                    3.779,
                    44.213
                ],
                "limit": 200,
                "page": 2,
                "datetime": "2017-05-05T00:00:00Z"
            }
        }
    }
]

or simplified implying the reuse of previous parameters:

"links": [
    {
        "rel": "self",
        "href": "https://stac-api.example.com/search",
        "type": "application/geo+json",
        "method": "POST"
    },
    {
        "rel": "next",
        "href": "https://stac-api.example.com/search",
        "type": "application/geo+json",
        "method": "POST",
        "body": {
                "page": 2
            }
        "merge": true
    }
]
philvarner commented 1 year ago

I think merge is preferred, since it's a bit easier to handle on the client side -- the client usually only needs to add the extra paging parameter (e.g., next=xkjlajdsfjaskdf) instead of reconstructing the entire query.

For the Item Search response from /search, there is no requirement for a self link, so there are no formal requirements for it. Planetary Computer only returns the base url (/search) without the merge and body parameters. OAFeat does require it for /items, but that endpoint only supports GET.

The easiest and most correct way would probably be to also add merge:true, so it actually means "make the same request"

    {
        "rel": "self",
        "href": "https://stac-api.example.com/search",
        "type": "application/geo+json",
        "method": "POST",
        "merge": true
    }