Skip to content

Module stac_fastapi.types.core

Base clients.

Variables

BASE_CONFORMANCE_CLASSES
NumType
STAC_VERSION
StacType
api_settings

Classes

AsyncBaseCoreClient

class AsyncBaseCoreClient(
    stac_version: str = '1.0.0',
    landing_page_id: str = 'stac-fastapi',
    title: str = 'stac-fastapi',
    description: str = 'stac-fastapi',
    base_conformance_classes: List[str] = NOTHING,
    extensions: List[stac_fastapi.types.extension.ApiExtension] = NOTHING,
    post_request_model=<class 'stac_fastapi.types.search.BaseSearchPostRequest'>
)

Defines a pattern for implementing STAC api core endpoints.

Attributes

Name Type Description Default
extensions None list of registered api extensions. None

Ancestors (in MRO)

  • stac_fastapi.types.core.LandingPageMixin
  • abc.ABC

Class variables

post_request_model

Methods

all_collections

def all_collections(
    self,
    **kwargs
) -> stac_fastapi.types.stac.Collections

Get all available collections.

Called with GET /collections.

Returns:

Type Description
None A list of collections.

conformance

def conformance(
    self,
    **kwargs
) -> stac_fastapi.types.stac.Conformance

Conformance classes.

Called with GET /conformance.

Returns:

Type Description
None Conformance classes which the server conforms to.

conformance_classes

def conformance_classes(
    self
) -> List[str]

Generate conformance classes by adding extension conformance to base

conformance classes.

extension_is_enabled

def extension_is_enabled(
    self,
    extension: str
) -> bool

Check if an api extension is enabled.

get_collection

def get_collection(
    self,
    collection_id: str,
    **kwargs
) -> stac_fastapi.types.stac.Collection

Get collection by id.

Called with GET /collections/{collection_id}.

Parameters:

Name Type Description Default
collection_id None Id of the collection. None

Returns:

Type Description
None Collection.

get_item

def get_item(
    self,
    item_id: str,
    collection_id: str,
    **kwargs
) -> stac_fastapi.types.stac.Item

Get item by id.

Called with GET /collections/{collection_id}/items/{item_id}.

Parameters:

Name Type Description Default
item_id None Id of the item. None
collection_id None Id of the collection. None

Returns:

Type Description
None Item.
def get_search(
    self,
    collections: Union[List[str], NoneType] = None,
    ids: Union[List[str], NoneType] = None,
    bbox: Union[Tuple[Union[float, int], Union[float, int], Union[float, int], Union[float, int]], Tuple[Union[float, int], Union[float, int], Union[float, int], Union[float, int], Union[float, int], Union[float, int]], NoneType] = None,
    datetime: Union[datetime.datetime, Tuple[datetime.datetime, datetime.datetime], Tuple[datetime.datetime, NoneType], Tuple[NoneType, datetime.datetime], NoneType] = None,
    limit: Union[int, NoneType] = 10,
    query: Union[str, NoneType] = None,
    token: Union[str, NoneType] = None,
    fields: Union[List[str], NoneType] = None,
    sortby: Union[str, NoneType] = None,
    intersects: Union[str, NoneType] = None,
    **kwargs
) -> stac_fastapi.types.stac.ItemCollection

Cross catalog search (GET).

Called with GET /search.

Returns:

Type Description
None ItemCollection containing items which match the search criteria.

item_collection

def item_collection(
    self,
    collection_id: str,
    bbox: Union[Tuple[Union[float, int], Union[float, int], Union[float, int], Union[float, int]], Tuple[Union[float, int], Union[float, int], Union[float, int], Union[float, int], Union[float, int], Union[float, int]], NoneType] = None,
    datetime: Union[datetime.datetime, Tuple[datetime.datetime, datetime.datetime], Tuple[datetime.datetime, NoneType], Tuple[NoneType, datetime.datetime], NoneType] = None,
    limit: int = 10,
    token: str = None,
    **kwargs
) -> stac_fastapi.types.stac.ItemCollection

Get all items from a specific collection.

Called with GET /collections/{collection_id}/items

Parameters:

Name Type Description Default
collection_id None id of the collection. None
limit None number of items to return. None
token None pagination token. None

Returns:

Type Description
None An ItemCollection.

landing_page

def landing_page(
    self,
    **kwargs
) -> stac_fastapi.types.stac.LandingPage

Landing page.

Called with GET /.

Returns:

Type Description
None API landing page, serving as an entry point to the API.

post_search

def post_search(
    self,
    search_request: stac_fastapi.types.search.BaseSearchPostRequest,
    **kwargs
) -> stac_fastapi.types.stac.ItemCollection

Cross catalog search (POST).

Called with POST /search.

Parameters:

Name Type Description Default
search_request None search request parameters. None

Returns:

Type Description
None ItemCollection containing items which match the search criteria.

AsyncBaseFiltersClient

class AsyncBaseFiltersClient(

)

Defines a pattern for implementing the STAC filter extension.

Ancestors (in MRO)

  • abc.ABC

Methods

get_queryables

def get_queryables(
    self,
    collection_id: Union[str, NoneType] = None,
    **kwargs
) -> Dict[str, Any]

Get the queryables available for the given collection_id.

If collection_id is None, returns the intersection of all queryables over all collections.

This base implementation returns a blank queryable schema. This is not allowed under OGC CQL but it is allowed by the STAC API Filter Extension github.com/radiantearth/stac-api-spec/tree/master/fragments/filter#queryables

AsyncBaseTransactionsClient

class AsyncBaseTransactionsClient(

)

Defines a pattern for implementing the STAC transaction extension.

Ancestors (in MRO)

  • abc.ABC

Methods

create_collection

def create_collection(
    self,
    collection: stac_fastapi.types.stac.Collection,
    **kwargs
) -> Union[stac_fastapi.types.stac.Collection, starlette.responses.Response, NoneType]

Create a new collection.

Called with POST /collections.

Parameters:

Name Type Description Default
collection None the collection None

Returns:

Type Description
None The collection that was created.

create_item

def create_item(
    self,
    collection_id: str,
    item: Union[stac_fastapi.types.stac.Item, stac_fastapi.types.stac.ItemCollection],
    **kwargs
) -> Union[stac_fastapi.types.stac.Item, starlette.responses.Response, NoneType]

Create a new item.

Called with POST /collections/{collection_id}/items.

Parameters:

Name Type Description Default
item None the item or item collection None
collection_id None the id of the collection from the resource path None

Returns:

Type Description
None The item that was created or None if item collection.

delete_collection

def delete_collection(
    self,
    collection_id: str,
    **kwargs
) -> Union[stac_fastapi.types.stac.Collection, starlette.responses.Response, NoneType]

Delete a collection.

Called with DELETE /collections/{collection_id}

Parameters:

Name Type Description Default
collection_id None id of the collection. None

Returns:

Type Description
None The deleted collection.

delete_item

def delete_item(
    self,
    item_id: str,
    collection_id: str,
    **kwargs
) -> Union[stac_fastapi.types.stac.Item, starlette.responses.Response, NoneType]

Delete an item from a collection.

Called with DELETE /collections/{collection_id}/items/{item_id}

Parameters:

Name Type Description Default
item_id None id of the item. None
collection_id None id of the collection. None

Returns:

Type Description
None The deleted item.

update_collection

def update_collection(
    self,
    collection_id: str,
    collection: stac_fastapi.types.stac.Collection,
    **kwargs
) -> Union[stac_fastapi.types.stac.Collection, starlette.responses.Response, NoneType]

Perform a complete update on an existing collection.

Called with PUT /collections/{collection_id}. It is expected that this item already exists. The update should do a diff against the saved collection and perform any necessary updates. Partial updates are not supported by the transactions extension.

Parameters:

Name Type Description Default
collection_id None id of the existing collection to be updated None
collection None the updated collection (must be complete) None

Returns:

Type Description
None The updated collection.

update_item

def update_item(
    self,
    collection_id: str,
    item_id: str,
    item: stac_fastapi.types.stac.Item,
    **kwargs
) -> Union[stac_fastapi.types.stac.Item, starlette.responses.Response, NoneType]

Perform a complete update on an existing item.

Called with PUT /collections/{collection_id}/items. It is expected that this item already exists. The update should do a diff against the saved item and perform any necessary updates. Partial updates are not supported by the transactions extension.

Parameters:

Name Type Description Default
item None the item (must be complete) None

Returns:

Type Description
None The updated item.

BaseCoreClient

class BaseCoreClient(
    stac_version: str = '1.0.0',
    landing_page_id: str = 'stac-fastapi',
    title: str = 'stac-fastapi',
    description: str = 'stac-fastapi',
    base_conformance_classes: List[str] = NOTHING,
    extensions: List[stac_fastapi.types.extension.ApiExtension] = NOTHING,
    post_request_model=<class 'stac_fastapi.types.search.BaseSearchPostRequest'>
)

Defines a pattern for implementing STAC api core endpoints.

Attributes

Name Type Description Default
extensions None list of registered api extensions. None

Ancestors (in MRO)

  • stac_fastapi.types.core.LandingPageMixin
  • abc.ABC

Class variables

post_request_model

Methods

all_collections

def all_collections(
    self,
    **kwargs
) -> stac_fastapi.types.stac.Collections

Get all available collections.

Called with GET /collections.

Returns:

Type Description
None A list of collections.

conformance

def conformance(
    self,
    **kwargs
) -> stac_fastapi.types.stac.Conformance

Conformance classes.

Called with GET /conformance.

Returns:

Type Description
None Conformance classes which the server conforms to.

conformance_classes

def conformance_classes(
    self
) -> List[str]

Generate conformance classes by adding extension conformance to base

conformance classes.

extension_is_enabled

def extension_is_enabled(
    self,
    extension: str
) -> bool

Check if an api extension is enabled.

get_collection

def get_collection(
    self,
    collection_id: str,
    **kwargs
) -> stac_fastapi.types.stac.Collection

Get collection by id.

Called with GET /collections/{collection_id}.

Parameters:

Name Type Description Default
collection_id None Id of the collection. None

Returns:

Type Description
None Collection.

get_item

def get_item(
    self,
    item_id: str,
    collection_id: str,
    **kwargs
) -> stac_fastapi.types.stac.Item

Get item by id.

Called with GET /collections/{collection_id}/items/{item_id}.

Parameters:

Name Type Description Default
item_id None Id of the item. None
collection_id None Id of the collection. None

Returns:

Type Description
None Item.

get_search

def get_search(
    self,
    collections: Union[List[str], NoneType] = None,
    ids: Union[List[str], NoneType] = None,
    bbox: Union[Tuple[Union[float, int], Union[float, int], Union[float, int], Union[float, int]], Tuple[Union[float, int], Union[float, int], Union[float, int], Union[float, int], Union[float, int], Union[float, int]], NoneType] = None,
    datetime: Union[datetime.datetime, Tuple[datetime.datetime, datetime.datetime], Tuple[datetime.datetime, NoneType], Tuple[NoneType, datetime.datetime], NoneType] = None,
    limit: Union[int, NoneType] = 10,
    query: Union[str, NoneType] = None,
    token: Union[str, NoneType] = None,
    fields: Union[List[str], NoneType] = None,
    sortby: Union[str, NoneType] = None,
    intersects: Union[str, NoneType] = None,
    **kwargs
) -> stac_fastapi.types.stac.ItemCollection

Cross catalog search (GET).

Called with GET /search.

Returns:

Type Description
None ItemCollection containing items which match the search criteria.

item_collection

def item_collection(
    self,
    collection_id: str,
    bbox: Union[Tuple[Union[float, int], Union[float, int], Union[float, int], Union[float, int]], Tuple[Union[float, int], Union[float, int], Union[float, int], Union[float, int], Union[float, int], Union[float, int]], NoneType] = None,
    datetime: Union[datetime.datetime, Tuple[datetime.datetime, datetime.datetime], Tuple[datetime.datetime, NoneType], Tuple[NoneType, datetime.datetime], NoneType] = None,
    limit: int = 10,
    token: str = None,
    **kwargs
) -> stac_fastapi.types.stac.ItemCollection

Get all items from a specific collection.

Called with GET /collections/{collection_id}/items

Parameters:

Name Type Description Default
collection_id None id of the collection. None
limit None number of items to return. None
token None pagination token. None

Returns:

Type Description
None An ItemCollection.

landing_page

def landing_page(
    self,
    **kwargs
) -> stac_fastapi.types.stac.LandingPage

Landing page.

Called with GET /.

Returns:

Type Description
None API landing page, serving as an entry point to the API.

list_conformance_classes

def list_conformance_classes(
    self
)

Return a list of conformance classes, including implemented extensions.

post_search

def post_search(
    self,
    search_request: stac_fastapi.types.search.BaseSearchPostRequest,
    **kwargs
) -> stac_fastapi.types.stac.ItemCollection

Cross catalog search (POST).

Called with POST /search.

Parameters:

Name Type Description Default
search_request None search request parameters. None

Returns:

Type Description
None ItemCollection containing items which match the search criteria.

BaseFiltersClient

class BaseFiltersClient(

)

Defines a pattern for implementing the STAC filter extension.

Ancestors (in MRO)

  • abc.ABC

Methods

get_queryables

def get_queryables(
    self,
    collection_id: Union[str, NoneType] = None,
    **kwargs
) -> Dict[str, Any]

Get the queryables available for the given collection_id.

If collection_id is None, returns the intersection of all queryables over all collections.

This base implementation returns a blank queryable schema. This is not allowed under OGC CQL but it is allowed by the STAC API Filter Extension stac-api-extensions/filter#queryables

BaseTransactionsClient

class BaseTransactionsClient(

)

Defines a pattern for implementing the STAC API Transaction Extension.

Ancestors (in MRO)

  • abc.ABC

Methods

create_collection

def create_collection(
    self,
    collection: stac_fastapi.types.stac.Collection,
    **kwargs
) -> Union[stac_fastapi.types.stac.Collection, starlette.responses.Response, NoneType]

Create a new collection.

Called with POST /collections.

Parameters:

Name Type Description Default
collection None the collection None

Returns:

Type Description
None The collection that was created.

create_item

def create_item(
    self,
    collection_id: str,
    item: Union[stac_fastapi.types.stac.Item, stac_fastapi.types.stac.ItemCollection],
    **kwargs
) -> Union[stac_fastapi.types.stac.Item, starlette.responses.Response, NoneType]

Create a new item.

Called with POST /collections/{collection_id}/items.

Parameters:

Name Type Description Default
item None the item or item collection None
collection_id None the id of the collection from the resource path None

Returns:

Type Description
None The item that was created or None if item collection.

delete_collection

def delete_collection(
    self,
    collection_id: str,
    **kwargs
) -> Union[stac_fastapi.types.stac.Collection, starlette.responses.Response, NoneType]

Delete a collection.

Called with DELETE /collections/{collection_id}

Parameters:

Name Type Description Default
collection_id None id of the collection. None

Returns:

Type Description
None The deleted collection.

delete_item

def delete_item(
    self,
    item_id: str,
    collection_id: str,
    **kwargs
) -> Union[stac_fastapi.types.stac.Item, starlette.responses.Response, NoneType]

Delete an item from a collection.

Called with DELETE /collections/{collection_id}/items/{item_id}

Parameters:

Name Type Description Default
item_id None id of the item. None
collection_id None id of the collection. None

Returns:

Type Description
None The deleted item.

update_collection

def update_collection(
    self,
    collection_id: str,
    collection: stac_fastapi.types.stac.Collection,
    **kwargs
) -> Union[stac_fastapi.types.stac.Collection, starlette.responses.Response, NoneType]

Perform a complete update on an existing collection.

Called with PUT /collections/{collection_id}. It is expected that this collection already exists. The update should do a diff against the saved collection and perform any necessary updates. Partial updates are not supported by the transactions extension.

Parameters:

Name Type Description Default
collection_id None id of the existing collection to be updated None
collection None the updated collection (must be complete) None

Returns:

Type Description
None The updated collection.

update_item

def update_item(
    self,
    collection_id: str,
    item_id: str,
    item: stac_fastapi.types.stac.Item,
    **kwargs
) -> Union[stac_fastapi.types.stac.Item, starlette.responses.Response, NoneType]

Perform a complete update on an existing item.

Called with PUT /collections/{collection_id}/items. It is expected that this item already exists. The update should do a diff against the saved item and perform any necessary updates. Partial updates are not supported by the transactions extension.

Parameters:

Name Type Description Default
item None the item (must be complete) None
collection_id None the id of the collection from the resource path None

Returns:

Type Description
None The updated item.

LandingPageMixin

class LandingPageMixin(
    stac_version: str = '1.0.0',
    landing_page_id: str = 'stac-fastapi',
    title: str = 'stac-fastapi',
    description: str = 'stac-fastapi'
)

Create a STAC landing page (GET /).

Ancestors (in MRO)

  • abc.ABC

Descendants

  • stac_fastapi.types.core.BaseCoreClient
  • stac_fastapi.types.core.AsyncBaseCoreClient