Skip to content

Module stac_fastapi.core.serializers

Serializers.

Classes

CollectionSerializer

class CollectionSerializer(

)

Serialization methods for STAC collections.

Ancestors (in MRO)

  • stac_fastapi.core.serializers.Serializer
  • abc.ABC

Static methods

db_to_stac

def db_to_stac(
    collection: dict,
    request: starlette.requests.Request,
    extensions: Union[List[str], NoneType] = []
) -> stac_fastapi.types.stac.Collection

Transform database model to STAC collection.

Parameters:

Name Type Description Default
collection dict The collection data in dictionary form, extracted from the database. None
starlette.requests.Request None the API request None
extensions None A list of the extension class names (ext.__name__) or all enabled STAC API extensions. None

Returns:

Type Description
stac_types.Collection The STAC collection object.

stac_to_db

def stac_to_db(
    collection: stac_fastapi.types.stac.Collection,
    request: starlette.requests.Request
) -> stac_fastapi.types.stac.Collection

Transform STAC Collection to database-ready STAC collection.

Parameters:

Name Type Description Default
stac_data None the STAC Collection object to be transformed None
starlette.requests.Request None the API request None

Returns:

Type Description
stac_types.Collection The database-ready STAC Collection object.

ItemSerializer

class ItemSerializer(

)

Serialization methods for STAC items.

Ancestors (in MRO)

  • stac_fastapi.core.serializers.Serializer
  • abc.ABC

Static methods

db_to_stac

def db_to_stac(
    item: dict,
    base_url: str
) -> stac_fastapi.types.stac.Item

Transform database-ready STAC item to STAC item.

Parameters:

Name Type Description Default
item dict The database-ready STAC item to be transformed. None
base_url str The base URL for the STAC API. None

Returns:

Type Description
stac_types.Item The STAC item object.

stac_to_db

def stac_to_db(
    stac_data: stac_fastapi.types.stac.Item,
    base_url: str
) -> stac_fastapi.types.stac.Item

Transform STAC item to database-ready STAC item.

Parameters:

Name Type Description Default
stac_data stac_types.Item The STAC item object to be transformed. None
base_url str The base URL for the STAC API. None

Returns:

Type Description
stac_types.Item The database-ready STAC item object.

Serializer

class Serializer(

)

Defines serialization methods between the API and the data model.

This class is meant to be subclassed and implemented by specific serializers for different STAC objects (e.g. Item, Collection).

Ancestors (in MRO)

  • abc.ABC

Descendants

  • stac_fastapi.core.serializers.ItemSerializer
  • stac_fastapi.core.serializers.CollectionSerializer

Static methods

db_to_stac

def db_to_stac(
    item: dict,
    base_url: str
) -> Any

Transform database model to STAC object.

Parameters:

Name Type Description Default
item dict A dictionary representing the database model. None
base_url str The base URL of the STAC API. None

Returns:

Type Description
Any A STAC object, e.g. an Item or Collection, representing the input item.

stac_to_db

def stac_to_db(
    stac_object: Any,
    base_url: str
) -> dict

Transform STAC object to database model.

Parameters:

Name Type Description Default
stac_object Any A STAC object, e.g. an Item or Collection. None
base_url str The base URL of the STAC API. None

Returns:

Type Description
dict A dictionary representing the database model.