Aggregate Asset Count

async AsyncCogniteClient.assets.aggregate_count(
property: AssetProperty | str | list[str] | None = None,
advanced_filter: Filter | dict[str, Any] | None = None,
filter: AssetFilter | dict[str, Any] | None = None,
) int

Count of assets matching the specified filters.

Parameters:
  • property (AssetPropertyLike | None) – If specified, get an approximate number of asset with a specific property (property is not null) and matching the filters.

  • advanced_filter (Filter | dict[str, Any] | None) – The advanced filter to narrow down the assets to count.

  • filter (AssetFilter | dict[str, Any] | None) – The filter to narrow down the assets to count (strict matching).

Returns:

The number of assets matching the specified filters.

Return type:

int

Examples:

Count the number of assets in your CDF project:

>>> from cognite.client import CogniteClient, AsyncCogniteClient
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> count = client.assets.aggregate_count()

Count the number of assets with the metadata key “timezone” in your CDF project:

>>> from cognite.client.data_classes.filters import ContainsAny
>>> from cognite.client.data_classes.assets import AssetProperty
>>> has_timezone = ContainsAny(AssetProperty.metadata, "timezone")
>>> asset_count = client.assets.aggregate_count(advanced_filter=has_timezone)