curl --request POST \
--url https://api.mixpeek.com/v1/buckets/{bucket_identifier}/objects/aggregate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Namespace: <api-key>' \
--data '
{
"aggregations": [
{
"alias": "total",
"function": "count"
}
],
"description": "Count objects by status",
"group_by": [
{
"alias": "status",
"field": "status"
}
],
"sort_by": "total",
"sort_direction": "desc"
}
'import requests
url = "https://api.mixpeek.com/v1/buckets/{bucket_identifier}/objects/aggregate"
payload = {
"aggregations": [
{
"alias": "total",
"function": "count"
}
],
"description": "Count objects by status",
"group_by": [
{
"alias": "status",
"field": "status"
}
],
"sort_by": "total",
"sort_direction": "desc"
}
headers = {
"Authorization": "Bearer <token>",
"X-Namespace": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'X-Namespace': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
aggregations: [{alias: 'total', function: 'count'}],
description: 'Count objects by status',
group_by: [{alias: 'status', field: 'status'}],
sort_by: 'total',
sort_direction: 'desc'
})
};
fetch('https://api.mixpeek.com/v1/buckets/{bucket_identifier}/objects/aggregate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mixpeek.com/v1/buckets/{bucket_identifier}/objects/aggregate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'aggregations' => [
[
'alias' => 'total',
'function' => 'count'
]
],
'description' => 'Count objects by status',
'group_by' => [
[
'alias' => 'status',
'field' => 'status'
]
],
'sort_by' => 'total',
'sort_direction' => 'desc'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Namespace: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mixpeek.com/v1/buckets/{bucket_identifier}/objects/aggregate"
payload := strings.NewReader("{\n \"aggregations\": [\n {\n \"alias\": \"total\",\n \"function\": \"count\"\n }\n ],\n \"description\": \"Count objects by status\",\n \"group_by\": [\n {\n \"alias\": \"status\",\n \"field\": \"status\"\n }\n ],\n \"sort_by\": \"total\",\n \"sort_direction\": \"desc\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("X-Namespace", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mixpeek.com/v1/buckets/{bucket_identifier}/objects/aggregate")
.header("Authorization", "Bearer <token>")
.header("X-Namespace", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"aggregations\": [\n {\n \"alias\": \"total\",\n \"function\": \"count\"\n }\n ],\n \"description\": \"Count objects by status\",\n \"group_by\": [\n {\n \"alias\": \"status\",\n \"field\": \"status\"\n }\n ],\n \"sort_by\": \"total\",\n \"sort_direction\": \"desc\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixpeek.com/v1/buckets/{bucket_identifier}/objects/aggregate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["X-Namespace"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"aggregations\": [\n {\n \"alias\": \"total\",\n \"function\": \"count\"\n }\n ],\n \"description\": \"Count objects by status\",\n \"group_by\": [\n {\n \"alias\": \"status\",\n \"field\": \"status\"\n }\n ],\n \"sort_by\": \"total\",\n \"sort_direction\": \"desc\"\n}"
response = http.request(request)
puts response.read_body{
"query_info": {
"execution_time_ms": 45,
"pipeline_stages": 5
},
"results": [
{
"group": {
"status": "completed"
},
"metrics": {
"total": 1523
}
},
{
"group": {
"status": "pending"
},
"metrics": {
"total": 87
}
}
],
"total_groups": 2
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}Aggregate Objects
This endpoint performs aggregation operations on objects in a bucket.
Aggregation operations:
- GROUP BY: Group objects by one or more fields
- Aggregations: COUNT, SUM, AVG, MIN, MAX, COUNT_DISTINCT, etc.
- Date Operations: Truncate or extract date parts for time-series analysis
- Filtering: Pre-aggregation filters (WHERE) and post-aggregation filters (HAVING)
- Sorting & Limiting: Control result ordering and size
Use Cases:
- Count objects by status or category
- Calculate daily/monthly upload statistics
- Analyze content distribution and trends
- Generate reports with multiple metrics
Bucket Objects: An object is one item stored in a bucket: a file or other blob plus the fields and metadata you attach to it. Collections read objects and turn them into searchable documents, and each document keeps a link back to the object it came from. Read the guide.
curl --request POST \
--url https://api.mixpeek.com/v1/buckets/{bucket_identifier}/objects/aggregate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Namespace: <api-key>' \
--data '
{
"aggregations": [
{
"alias": "total",
"function": "count"
}
],
"description": "Count objects by status",
"group_by": [
{
"alias": "status",
"field": "status"
}
],
"sort_by": "total",
"sort_direction": "desc"
}
'import requests
url = "https://api.mixpeek.com/v1/buckets/{bucket_identifier}/objects/aggregate"
payload = {
"aggregations": [
{
"alias": "total",
"function": "count"
}
],
"description": "Count objects by status",
"group_by": [
{
"alias": "status",
"field": "status"
}
],
"sort_by": "total",
"sort_direction": "desc"
}
headers = {
"Authorization": "Bearer <token>",
"X-Namespace": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'X-Namespace': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
aggregations: [{alias: 'total', function: 'count'}],
description: 'Count objects by status',
group_by: [{alias: 'status', field: 'status'}],
sort_by: 'total',
sort_direction: 'desc'
})
};
fetch('https://api.mixpeek.com/v1/buckets/{bucket_identifier}/objects/aggregate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mixpeek.com/v1/buckets/{bucket_identifier}/objects/aggregate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'aggregations' => [
[
'alias' => 'total',
'function' => 'count'
]
],
'description' => 'Count objects by status',
'group_by' => [
[
'alias' => 'status',
'field' => 'status'
]
],
'sort_by' => 'total',
'sort_direction' => 'desc'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Namespace: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mixpeek.com/v1/buckets/{bucket_identifier}/objects/aggregate"
payload := strings.NewReader("{\n \"aggregations\": [\n {\n \"alias\": \"total\",\n \"function\": \"count\"\n }\n ],\n \"description\": \"Count objects by status\",\n \"group_by\": [\n {\n \"alias\": \"status\",\n \"field\": \"status\"\n }\n ],\n \"sort_by\": \"total\",\n \"sort_direction\": \"desc\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("X-Namespace", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mixpeek.com/v1/buckets/{bucket_identifier}/objects/aggregate")
.header("Authorization", "Bearer <token>")
.header("X-Namespace", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"aggregations\": [\n {\n \"alias\": \"total\",\n \"function\": \"count\"\n }\n ],\n \"description\": \"Count objects by status\",\n \"group_by\": [\n {\n \"alias\": \"status\",\n \"field\": \"status\"\n }\n ],\n \"sort_by\": \"total\",\n \"sort_direction\": \"desc\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixpeek.com/v1/buckets/{bucket_identifier}/objects/aggregate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["X-Namespace"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"aggregations\": [\n {\n \"alias\": \"total\",\n \"function\": \"count\"\n }\n ],\n \"description\": \"Count objects by status\",\n \"group_by\": [\n {\n \"alias\": \"status\",\n \"field\": \"status\"\n }\n ],\n \"sort_by\": \"total\",\n \"sort_direction\": \"desc\"\n}"
response = http.request(request)
puts response.read_body{
"query_info": {
"execution_time_ms": 45,
"pipeline_stages": 5
},
"results": [
{
"group": {
"status": "completed"
},
"metrics": {
"total": 1523
}
},
{
"group": {
"status": "pending"
},
"metrics": {
"total": 87
}
}
],
"total_groups": 2
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}{
"error": {
"details": {
"id": "ns_123",
"resource": "namespace"
},
"message": "Namespace not found",
"type": "NotFoundError"
},
"status": 404,
"success": false
}Authorizations
Mixpeek API key, sent as Authorization: Bearer mxp_sk_.... Create one in Studio under Settings → API Keys, or with an admin key via POST /v1/organizations/users/{user_email}/api-keys. A missing, malformed, unknown, revoked, inactive or expired key returns 401; a key without the permission, scope or plan an operation needs returns 403.
Body
Keys this body does not declare are refused with 422 extra_forbidden naming the accepted keys (since 2026-11-02).
Aggregation configuration specifying grouping, metrics, and filters.
Response
Successful Response
Response containing object aggregation results.
Returns aggregated statistics grouped by specified fields.
Was this page helpful?

