Skip to content

API client

rustac.ApiClient

A client for searching a STAC API server.

__init__

__init__(
    href: str,
    *,
    headers: dict[str, str] | None = None,
    max_extra_load: float | None = None,
    max_retries_per_request: int | None = None,
    retry_status_codes: list[int] | None = None,
) -> None

Creates a new STAC API client.

Parameters:

  • href (str) –

    The root href of the STAC API.

  • headers (dict[str, str] | None, default: None ) –

    Additional headers to include in every request to the API.

  • max_extra_load (float | None, default: None ) –

    The maximum extra load that retries are allowed to add to the server, as a fraction of the request rate. See the reqwest docs.

  • max_retries_per_request (int | None, default: None ) –

    The maximum number of retries for a single request.

  • retry_status_codes (list[int] | None, default: None ) –

    The HTTP status codes that should trigger a retry (e.g. [408, 429, 500, 502, 503, 504]).

get_collection async

get_collection(id: str) -> dict[str, Any]

Gets a single collection by id.

Parameters:

  • id (str) –

    The collection id.

Returns:

  • dict[str, Any]

    The STAC collection.

get_collection_sync

get_collection_sync(id: str) -> dict[str, Any]

Gets a single collection by id, synchronously.

Parameters:

  • id (str) –

    The collection id.

Returns:

  • dict[str, Any]

    The STAC collection.

get_collections async

get_collections() -> list[dict[str, Any]]

Gets all collections from the API.

Returns:

  • list[dict[str, Any]]

    The STAC collections.

get_collections_sync

get_collections_sync() -> list[dict[str, Any]]

Gets all collections from the API, synchronously.

Returns:

  • list[dict[str, Any]]

    The STAC collections.

iter_search(
    *,
    intersects: str | dict[str, Any] | None = None,
    ids: str | list[str] | None = None,
    collections: str | list[str] | None = None,
    limit: int | None = None,
    bbox: list[float] | None = None,
    datetime: str | None = None,
    include: str | list[str] | None = None,
    exclude: str | list[str] | None = None,
    sortby: str | list[str | dict[str, str]] | None = None,
    filter: str | dict[str, Any] | None = None,
    query: dict[str, Any] | None = None,
    fields: str | list[str] | dict[str, Any] | None = None,
    **kwargs: str,
) -> AsyncIterator[dict[str, Any]]

Searches the API, asynchronously iterating over matching items.

search async

search(
    *,
    intersects: str | dict[str, Any] | None = None,
    ids: str | list[str] | None = None,
    collections: str | list[str] | None = None,
    max_items: int | None = None,
    limit: int | None = None,
    bbox: list[float] | None = None,
    datetime: str | None = None,
    include: str | list[str] | None = None,
    exclude: str | list[str] | None = None,
    sortby: str | list[str | dict[str, str]] | None = None,
    filter: str | dict[str, Any] | None = None,
    query: dict[str, Any] | None = None,
    fields: str | list[str] | dict[str, Any] | None = None,
    **kwargs: str,
) -> list[dict[str, Any]]

Searches the API, returning all matching items as a list.

search_sync

search_sync(
    *,
    intersects: str | dict[str, Any] | None = None,
    ids: str | list[str] | None = None,
    collections: str | list[str] | None = None,
    max_items: int | None = None,
    limit: int | None = None,
    bbox: list[float] | None = None,
    datetime: str | None = None,
    include: str | list[str] | None = None,
    exclude: str | list[str] | None = None,
    sortby: str | list[str | dict[str, str]] | None = None,
    filter: str | dict[str, Any] | None = None,
    query: dict[str, Any] | None = None,
    fields: str | list[str] | dict[str, Any] | None = None,
    **kwargs: str,
) -> list[dict[str, Any]]

Searches the API synchronously, returning all matching items as a list.