Skip to content

Module stac_fastapi.pgstac.core

Item crud client.

Variables

NumType

Functions

clean_search_args

def clean_search_args(
    base_args: Dict[str, Any],
    intersects: Optional[str] = None,
    datetime: Union[datetime.datetime, Tuple[datetime.datetime, datetime.datetime], Tuple[datetime.datetime, NoneType], Tuple[NoneType, datetime.datetime], NoneType] = None,
    fields: Optional[List[str]] = None,
    sortby: Optional[str] = None,
    filter_query: Optional[str] = None,
    filter_lang: Optional[str] = None
) -> Dict[str, Any]

Clean up search arguments to match format expected by pgstac

Classes

CoreCrudClient

class CoreCrudClient(
    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'>
)

Client for core endpoints defined by stac.

Ancestors (in MRO)

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

Methods

all_collections

def all_collections(
    self,
    request: starlette.requests.Request,
    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: Optional[int] = None,
    query: Optional[str] = None,
    token: Optional[str] = None,
    fields: Optional[List[str]] = None,
    sortby: Optional[str] = None,
    filter: Optional[str] = None,
    filter_lang: Optional[str] = None,
    **kwargs
) -> stac_fastapi.types.stac.Collections

Cross catalog search (GET).

Called with GET /collections.

Returns:

Type Description
None Collections which match the search criteria, returns all
collections by default.

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,
    request: starlette.requests.Request,
    **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,
    request: starlette.requests.Request,
    **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 the item is in. None

Returns:

Type Description
None Item.
def get_search(
    self,
    request: starlette.requests.Request,
    collections: Optional[List[str]] = None,
    ids: Optional[List[str]] = 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,
    intersects: Optional[str] = None,
    datetime: Union[datetime.datetime, Tuple[datetime.datetime, datetime.datetime], Tuple[datetime.datetime, NoneType], Tuple[NoneType, datetime.datetime], NoneType] = None,
    limit: Optional[int] = None,
    query: Optional[str] = None,
    token: Optional[str] = None,
    fields: Optional[List[str]] = None,
    sortby: Optional[str] = None,
    filter: Optional[str] = None,
    filter_lang: Optional[str] = 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,
    request: starlette.requests.Request,
    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: Optional[int] = None,
    token: Optional[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.pgstac.types.search.PgstacSearch,
    request: starlette.requests.Request,
    **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.