Skip to main content
POST
/
documents
/
aggregate
Python SDK
from cognite.client.data_classes.documents import SourceFileProperty
count = client.documents.aggregate_cardinality_properties(SourceFileProperty.metadata)
from cognite.client.data_classes.documents import DocumentProperty
count = client.documents.aggregate_cardinality_values(DocumentProperty.type)

from cognite.client.data_classes import filters
from cognite.client.data_classes.documents import DocumentProperty
is_plain_text = filters.Equals(DocumentProperty.mime_type, "text/plain")
plain_text_author_count = client.documents.aggregate_cardinality_values(DocumentProperty.author, filter=is_plain_text)

from cognite.client.data_classes.documents import DocumentProperty
from cognite.client.data_classes import aggregations
agg = aggregations
is_not_text = agg.Not(agg.Prefix("text"))
type_count_excluded_text = client.documents.aggregate_cardinality_values(DocumentProperty.type, aggregate_filter=is_not_text)
count = client.documents.aggregate_count()

from cognite.client.data_classes import filters
from cognite.client.data_classes.documents import DocumentProperty
is_pdf = filters.Equals(DocumentProperty.mime_type, "application/pdf")
pdf_count = client.documents.aggregate_count(filter=is_pdf)

client.documents.aggregate_count(
    filter=filters.InAssetSubtree(
        property=DocumentProperty.asset_external_ids,
        values=['Plant_1', 'Plant_2'],
    )
)
from cognite.client.data_classes.documents import SourceFileProperty
result = client.documents.aggregate_unique_values(SourceFileProperty.metadata)
from cognite.client.data_classes.documents import DocumentProperty
result = client.documents.aggregate_unique_values(DocumentProperty.mime_type)
unique_types = result.unique

from cognite.client.data_classes import filters
from cognite.client.data_classes.documents import DocumentProperty
is_abc = filters.Prefix(DocumentProperty.external_id, "abc")
result = client.documents.aggregate_unique_values(DocumentProperty.language, filter=is_abc)
unique_languages = result.unique

from cognite.client.data_classes.documents import DocumentProperty
from cognite.client.data_classes import aggregations
agg = aggregations
is_not_text = agg.Not(agg.Prefix("text"))
result = client.documents.aggregate_unique_values(DocumentProperty.mime_type, aggregate_filter=is_not_text)
unique_mime_types = result.unique
{
  "items": [
    {
      "count": 10
    }
  ]
}

Authorizations

Authorization
string
header
required

Access token issued by the CDF project's configured identity provider. Access token must be an OpenID Connect token, and the project must be configured to accept OpenID Connect tokens. Use a header key of 'Authorization' with a value of 'Bearer $accesstoken'. The token can be obtained through any flow supported by the identity provider.

Body

application/json

Count of documents.

filter
and · object

A query that matches items matching boolean combinations of other queries. It is built using one or more boolean clauses, which can be of types: and, or or not

aggregate
enum<string>
default:count

Count of documents matching the specified filters and search.

Available options:
count

Response

The results of an aggregation request. The object returned depends on the aggregate specified.

Response for count aggregate.

items
object[]
required
Required array length: 1 element
Last modified on April 23, 2026