- Title: Fields
- OpenAPI specification: openapi.yaml
- Conformance Classes:
STAC API - Item Searchbinding: https://api.stacspec.org/v1.0.0/item-search#fieldsSTAC API - Featuresbinding: https://api.stacspec.org/v1.0.0/ogcapi-features#fields
- Scope: STAC API - Features, STAC API - Item Search
- Extension Maturity Classification: Candidate
- Dependencies:
- Owner: none
By default, STAC API endpoints that return Item objects return every field of those Items. However, Item objects can have hundreds of fields, or large geometries, and even smaller Item objects can add up when large numbers of them are in results. Frequently, not all fields in an Item are used, so this specification provides a mechanism for clients to request that servers to explicitly include or exclude certain fields.
This behavior may be bound to either or both of
STAC API - Item Search (/search endpoint) or
STAC API - Features
(/collections/{collectionId}/items endpoint) by advertising the relevant conformance class.
When used in a POST request with Content-Type: application/json, this adds an attribute fields with
an object value to the core JSON search request body. The fields object contains two attributes with string array
values, include and exclude.
When used with GET, the semantics are the same, except the syntax is a single parameter fields with
a comma-separated list of field names, where exclude values are those prefixed by a - and include values are
those with no prefix, e.g., -geometry, or id,-geometry,properties.
It is recommended that implementations provide exactly the include and exclude sets specified by the request,
but this is not required. These values are only hints to the server as to the desires of the client, and not a
contract about what the response will be. Implementations are still considered compliant if fields not specified as part of include
are in the response or ones specified as part of exclude are. For example, implementations may choose to always
include simple string fields like id and type regardless of the exclude specification. However, it is recommended
that implementations honor excludes for fields with more complex and arbitrarily large values
(e.g., geometry, assets). For example, some Item objects may have a geometry with a simple 5 point polygon, but these
polygons can be very large when reprojected to EPSG:4326, as in the case of a highly-decimated sinusoidal polygons.
Implementations are also not required to implement semantics for nested values whereby one can include an object, but
exclude fields of that object, e.g., include properties but exclude properties.datetime.
No error must be returned if a specified field has no value for it in the catalog. For example, if the field "properties.eo:cloud_cover" is specified but there is no cloud cover value for an Item, a successful HTTP response must be returned and the Item entities will not contain that field.
If no fields are specified, the response is must be a valid
ItemCollection. If a client excludes
fields that are required in a STAC Item, the server may return an invalid STAC Item. For example, if type
and geometry are excluded, the entity will not even be a valid GeoJSON Feature, or if bbox is excluded then the entity
will not be a valid STAC Item.
Implementations may return fields not specified, e.g., id, but must avoid anything other than a minimal entity representation.
This specification does not yet require the implementation of an "-ables" endpoint (like CQL2 does for queryables)
that defines the names of the
fields that can be selected, so implementations must provide this out-of-band. Implementers may choose to require
fields in Item Properties to be prefixed with properties. or not, or support use of both the prefixed and non-prefixed
name, e.g., properties.datetime or datetime.
- If
fieldsattribute is specified as an empty string (GET requests) or as an empty object or an object with bothincludeandexcludeset to either null or an empty array (for POST requests), then the recommended behavior is to include only fieldstype,stac_version,id,geometry,bbox,links,assets, andproperties.datetime. Ifproperties.datetimeis null, then it is recommended to includeproperties.start_datetimeandproperties.end_datetime. These are the default fields to ensure a valid STAC Item is returned by default. Implementations may choose to include other properties, e.g.,properties.created, but the number of default properties fields should be kept to a minimum. - If only
includeis specified, these fields should be the only fields included. Any additional fields provided beyond those in theincludelist should be kept to a minimum, as the caller has explicitly stated they do not need them. - For POST requests, if only
excludeis specified, the specified fields should not be included, but every other field available for the Item should be included. - For POST requests, if
excludeis specified andincludeis null or an empty array, then theexcludefields should be excluded from the default set. This also applies to GET requests when onlyexcludefields are specified. - For nested fields (e.g.,
properties.datetime), the most specific path should be honored first, andincludeshould be preferred overexclude. For example:- If a field is in
exclude, and a nested field of that field is ininclude, the nested field should be included, but no other nested fields in the field should be included. For example, ifpropertiesis excluded andproperties.datetimeis included, thendatetimeshould be the only nested field inproperties. - If a field is in
include, and a nested field of that field is inexclude, the field should be included, and the nested field should be excluded. For example, ifpropertiesis included andproperties.datetimeis excluded, thendatetimeshould not be inproperties, but every other nested field should be.
- If a field is in
- If the same field is present in both
includeandexclude, it should be included. - If a field is not present in
include, but it is present inexclude, it should be excluded.
There is a semantic difference between a missing value (i.e., if include is not
in the JSON object), and a null or empty value. The recommended behavior
around missing vs. null and empty values is described in the section
above, but is summarized here for reference. "ALL"
means that all of the Item's fields should be returned; "DEFAULT" means the
default set (i.e. the required fields for a valid STAC Item) should be returned.
| include | exclude | returned |
|---|---|---|
missing, null, or empty |
missing, null, or empty |
DEFAULT |
| ["a", "b"] | missing, null, or empty |
["a", "b"] |
| missing | ["a", "b"] | ALL except for ["a", "b"] |
null or empty |
["a", "b"] | DEFAULT except for ["a", "b"] |
| ["a", "b"] | ["a"] | ["a", "b"] |
| ["a"] | ["a", "b"] | ["a"] |
| ["a.b"] | ["a"] | a.b should be the only field in a |
| ["a"] | ["a.b"] | a should be included, but it should not include a.b |
In this example, include is missing:
{
"fields": {
"exclude": ["geometry"]
}
}In these two examples, include is null and empty, respectively:
{
"fields": {
"include": null,
"exclude": ["geometry"]
}
}{
"fields": {
"include": [],
"exclude": ["geometry"]
}
}The special case of both include and exclude missing is possible both in
JSON and text. In JSON:
{
"fields": {}
}or
{
"fields": null
}In text:
?fields=
It is not possible to differentiate between missing, null, and empty for the
text representation, so implementations should assume the value is empty, NOT
missing. For example, this is a case of include being empty (NOT missing):
?fields=-geometry
Return the default fields. This should return valid STAC Item entities.
Query Parameters
?fields=
JSON
{
"fields": {
}
}Because implementations may choose to always include other fields (e.g.,
extension-specific fields such as
sar), this could has the same effect
as an empty object for fields.
Query Parameters
?fields=id,type,geometry,bbox,properties.datetime,links,assets,stac_version
JSON
{
"fields": {
"include": [
"id",
"type",
"geometry",
"bbox",
"properties.datetime",
"links",
"assets",
"stac_version",
]
}
}Exclude geometry from the full item. This will return an entity that is not a valid GeoJSON Feature or a valid STAC Item.
Query Parameters
?fields=-geometry
JSON
{
"fields": {
"exclude": [
"geometry"
]
}
}Return the id, type, geometry, and the Properties field eo:cloud_cover.
This is not guaranteed not return a valid STAC Item, since not all required Item
fields are included, but an implementor may choose to return a valid STAC
item anyways.
Query Parameters
?fields=id,type,geometry,properties.eo:cloud_cover
JSON
{
"fields": {
"include": [
"id",
"type",
"geometry",
"properties.eo:cloud_cover"
]
}
}To include id and all the properties fields, except for the foo field.
Query Parameters
?fields=id,properties,-properties.foo
also valid:
?fields=+id,+properties,-properties.foo
JSON
{
"fields": {
"include": [
"id",
"properties"
],
"exclude": [
"properties.foo"
]
}
}