Skip to main content
POST
/
v1
/
collections
/
{collection_identifier}
/
documents
/
distinct
Return distinct values for a single field.
curl --request POST \
  --url https://api.mixpeek.com/v1/collections/{collection_identifier}/documents/distinct \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "field": "<string>",
  "filters": {},
  "limit": 5000
}
'
{
  "field": "<string>",
  "values": [
    {
      "value": "<unknown>",
      "count": 123
    }
  ],
  "total_distinct": 123
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

collection_identifier
string
required

The unique identifier of the collection.

Body

application/json

Field + optional filters/limit for the distinct query.

field
string
required

Document field whose distinct values should be returned. Dotted paths are supported (e.g. metadata.brand_slug). Null/missing values are excluded.

Examples:

"brand_slug"

"metadata.category"

filters
Filters · object | null

Optional pre-aggregation filters, same syntax as the standard aggregation endpoint. Applied before distinct values are computed.

limit
integer | null

Maximum number of distinct values to return (sorted by count desc). Defaults to no limit on the server side; for high-cardinality fields always set a limit to keep the response bounded.

Required range: 1 <= x <= 10000

Response

Successful Response

Flat list of distinct values for a single field.

field
string
required

The field that was queried.

values
DistinctValue · object[]
required

Distinct values sorted by descending count. Respects the limit argument; use the length of this list as the returned count.

total_distinct
integer
required

Number of distinct values in the response (== len(values)). When limit is set this can be less than the true cardinality.