Skip to content

Module stac_fastapi.extensions.core

stac_api.extensions.core module.

Sub-modules

Classes

ContextExtension

class ContextExtension(
    conformance_classes: List[str] = NOTHING,
    schema_href: Optional[str] = 'https://raw.githubusercontent.com/stac-api-extensions/context/v1.0.0-rc.2/json-schema/schema.json'
)

Context Extension.

The Context extension adds a JSON object to ItemCollection responses (/search, /collections/{collection_id}/items) which includes the number of items matched, returned, and the limit requested. stac-api-extensions/context

Ancestors (in MRO)

  • stac_fastapi.types.extension.ApiExtension
  • abc.ABC

Class variables

GET
POST

Methods

get_request_model

def get_request_model(
    self,
    verb: Optional[str] = 'GET'
) -> Optional[pydantic.main.BaseModel]

Return the request model for the extension.method.

The model can differ based on HTTP verb

register

def register(
    self,
    app: fastapi.applications.FastAPI
) -> None

Register the extension with a FastAPI application.

Parameters:

Name Type Description Default
app None target FastAPI application. None

Returns:

Type Description
None None

FieldsExtension

class FieldsExtension(
    conformance_classes: List[str] = NOTHING,
    default_includes: Set[str] = NOTHING,
    schema_href: Optional[str] = None
)

Fields Extension.

The Fields extension adds functionality to the /search endpoint which allows the caller to include or exclude specific from the API response. Registering this extension with the application has the added effect of removing the ItemCollection response model from the /search endpoint, as the Fields extension allows the API to return potentially invalid responses by excluding fields which are required by the STAC spec, such as geometry.

stac-api-extensions/fields

Attributes

Name Type Description Default
default_includes set defines the default set of included fields. None
conformance_classes list Defines the list of conformance classes for
the extension
None

Ancestors (in MRO)

  • stac_fastapi.types.extension.ApiExtension
  • abc.ABC

Class variables

GET
POST

Methods

get_request_model

def get_request_model(
    self,
    verb: Optional[str] = 'GET'
) -> Optional[pydantic.main.BaseModel]

Return the request model for the extension.method.

The model can differ based on HTTP verb

register

def register(
    self,
    app: fastapi.applications.FastAPI
) -> None

Register the extension with a FastAPI application.

Parameters:

Name Type Description Default
app fastapi.FastAPI target FastAPI application. None

Returns:

Type Description
None None

FilterExtension

class FilterExtension(
    schema_href: Optional[str] = None,
    client: Union[stac_fastapi.types.core.AsyncBaseFiltersClient, stac_fastapi.types.core.BaseFiltersClient] = NOTHING,
    conformance_classes: List[str] = [<FilterConformanceClasses.FILTER: 'http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/filter'>, <FilterConformanceClasses.FEATURES_FILTER: 'http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/features-filter'>, <FilterConformanceClasses.ITEM_SEARCH_FILTER: 'https://api.stacspec.org/v1.0.0-rc.2/item-search#filter'>, <FilterConformanceClasses.BASIC_CQL2: 'http://www.opengis.net/spec/cql2/1.0/conf/basic-cql2'>, <FilterConformanceClasses.CQL2_JSON: 'http://www.opengis.net/spec/cql2/1.0/conf/cql2-json'>, <FilterConformanceClasses.CQL2_TEXT: 'http://www.opengis.net/spec/cql2/1.0/conf/cql2-text'>],
    router: fastapi.routing.APIRouter = NOTHING,
    response_class: Type[starlette.responses.Response] = <class 'stac_fastapi.api.models.JSONSchemaResponse'>
)

Filter Extension.

The filter extension adds several endpoints which allow the retrieval of queryables and provides an expressive mechanism for searching based on Item

Attributes

Name Type Description Default
client None Queryables endpoint logic None
conformance_classes None Conformance classes provided by the extension None

Ancestors (in MRO)

  • stac_fastapi.types.extension.ApiExtension
  • abc.ABC

Class variables

GET
POST

Methods

get_request_model

def get_request_model(
    self,
    verb: Optional[str] = 'GET'
) -> Optional[pydantic.main.BaseModel]

Return the request model for the extension.method.

The model can differ based on HTTP verb

register

def register(
    self,
    app: fastapi.applications.FastAPI
) -> None

Register the extension with a FastAPI application.

Parameters:

Name Type Description Default
app None target FastAPI application. None

Returns:

Type Description
None None

PaginationExtension

class PaginationExtension(
    conformance_classes: List[str] = NOTHING,
    schema_href: Optional[str] = None
)

Token Pagination.

Though not strictly an extension, the chosen pagination will modify the form of the request object. By making pagination an extension class, we can use create_request_model to dynamically add the correct pagination parameter to the request model for OpenAPI generation.

Ancestors (in MRO)

  • stac_fastapi.types.extension.ApiExtension
  • abc.ABC

Class variables

GET
POST

Methods

get_request_model

def get_request_model(
    self,
    verb: Optional[str] = 'GET'
) -> Optional[pydantic.main.BaseModel]

Return the request model for the extension.method.

The model can differ based on HTTP verb

register

def register(
    self,
    app: fastapi.applications.FastAPI
) -> None

Register the extension with a FastAPI application.

Parameters:

Name Type Description Default
app None target FastAPI application. None

Returns:

Type Description
None None

QueryExtension

class QueryExtension(
    conformance_classes: List[str] = NOTHING,
    schema_href: Optional[str] = None
)

Query Extension.

The Query extension adds an additional query parameter to /search requests which allows the caller to perform queries against item metadata (ex. find all images with cloud cover less than 15%). github.com/radiantearth/stac-api-spec/blob/master/item-search/README.md#query

Ancestors (in MRO)

  • stac_fastapi.types.extension.ApiExtension
  • abc.ABC

Class variables

GET
POST

Methods

get_request_model

def get_request_model(
    self,
    verb: Optional[str] = 'GET'
) -> Optional[pydantic.main.BaseModel]

Return the request model for the extension.method.

The model can differ based on HTTP verb

register

def register(
    self,
    app: fastapi.applications.FastAPI
) -> None

Register the extension with a FastAPI application.

Parameters:

Name Type Description Default
app None target FastAPI application. None

Returns:

Type Description
None None

SortExtension

class SortExtension(
    conformance_classes: List[str] = NOTHING,
    schema_href: Optional[str] = None
)

Sort Extension.

The Sort extension adds the sortby parameter to the /search endpoint, allowing the caller to specify the sort order of the returned items. stac-api-extensions/sort

Ancestors (in MRO)

  • stac_fastapi.types.extension.ApiExtension
  • abc.ABC

Class variables

GET
POST

Methods

get_request_model

def get_request_model(
    self,
    verb: Optional[str] = 'GET'
) -> Optional[pydantic.main.BaseModel]

Return the request model for the extension.method.

The model can differ based on HTTP verb

register

def register(
    self,
    app: fastapi.applications.FastAPI
) -> None

Register the extension with a FastAPI application.

Parameters:

Name Type Description Default
app None target FastAPI application. None

Returns:

Type Description
None None

TokenPaginationExtension

class TokenPaginationExtension(
    conformance_classes: List[str] = NOTHING,
    schema_href: Optional[str] = None
)

Token Pagination.

Though not strictly an extension, the chosen pagination will modify the form of the request object. By making pagination an extension class, we can use create_request_model to dynamically add the correct pagination parameter to the request model for OpenAPI generation.

Ancestors (in MRO)

  • stac_fastapi.types.extension.ApiExtension
  • abc.ABC

Class variables

GET
POST

Methods

get_request_model

def get_request_model(
    self,
    verb: Optional[str] = 'GET'
) -> Optional[pydantic.main.BaseModel]

Return the request model for the extension.method.

The model can differ based on HTTP verb

register

def register(
    self,
    app: fastapi.applications.FastAPI
) -> None

Register the extension with a FastAPI application.

Parameters:

Name Type Description Default
app None target FastAPI application. None

Returns:

Type Description
None None

TransactionExtension

class TransactionExtension(
    client: Union[stac_fastapi.types.core.AsyncBaseTransactionsClient, stac_fastapi.types.core.BaseTransactionsClient],
    settings: stac_fastapi.types.config.ApiSettings,
    conformance_classes: List[str] = NOTHING,
    schema_href: Optional[str] = None,
    router: fastapi.routing.APIRouter = NOTHING,
    response_class: Type[starlette.responses.Response] = <class 'starlette.responses.JSONResponse'>
)

Transaction Extension.

The transaction extension adds several endpoints which allow the creation, deletion, and updating of items and collections: POST /collections PUT /collections/{collection_id} DELETE /collections/{collection_id} POST /collections/{collection_id}/items PUT /collections/{collection_id}/items DELETE /collections/{collection_id}/items

github.com/radiantearth/stac-api-spec/blob/master/ogcapi-features/extensions/transaction/README.md

Attributes

Name Type Description Default
client None CRUD application logic None

Ancestors (in MRO)

  • stac_fastapi.types.extension.ApiExtension
  • abc.ABC

Class variables

GET
POST

Methods

get_request_model

def get_request_model(
    self,
    verb: Optional[str] = 'GET'
) -> Optional[pydantic.main.BaseModel]

Return the request model for the extension.method.

The model can differ based on HTTP verb

register

def register(
    self,
    app: fastapi.applications.FastAPI
) -> None

Register the extension with a FastAPI application.

Parameters:

Name Type Description Default
app None target FastAPI application. None

Returns:

Type Description
None None

register_create_collection

def register_create_collection(
    self
)

Register create collection endpoint (POST /collections).

register_create_item

def register_create_item(
    self
)

Register create item endpoint (POST /collections/{collection_id}/items).

register_delete_collection

def register_delete_collection(
    self
)

Register delete collection endpoint (DELETE /collections/{collection_id}).

register_delete_item

def register_delete_item(
    self
)

Register delete item endpoint (DELETE

/collections/{collection_id}/items/{item_id}).

register_update_collection

def register_update_collection(
    self
)

Register update collection endpoint (PUT /collections/{collection_id}).

register_update_item

def register_update_item(
    self
)

Register update item endpoint (PUT

/collections/{collection_id}/items/{item_id}).