Aggregate Records
Compute a sum, average, min, max, or count over a field, optionally filtered and grouped.
curl --request POST \
--url https://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/aggregate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"fieldId": "Amount",
"operation": "sum",
"filter": {
"field": "Status",
"equals": "Paid"
},
"groupBy": "Region"
}
'import requests
url = "https://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/aggregate"
payload = {
"fieldId": "Amount",
"operation": "sum",
"filter": {
"field": "Status",
"equals": "Paid"
},
"groupBy": "Region"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
fieldId: 'Amount',
operation: 'sum',
filter: {field: 'Status', equals: 'Paid'},
groupBy: 'Region'
})
};
fetch('https://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/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://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/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([
'fieldId' => 'Amount',
'operation' => 'sum',
'filter' => [
'field' => 'Status',
'equals' => 'Paid'
],
'groupBy' => 'Region'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/aggregate"
payload := strings.NewReader("{\n \"fieldId\": \"Amount\",\n \"operation\": \"sum\",\n \"filter\": {\n \"field\": \"Status\",\n \"equals\": \"Paid\"\n },\n \"groupBy\": \"Region\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/aggregate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"fieldId\": \"Amount\",\n \"operation\": \"sum\",\n \"filter\": {\n \"field\": \"Status\",\n \"equals\": \"Paid\"\n },\n \"groupBy\": \"Region\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/aggregate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"fieldId\": \"Amount\",\n \"operation\": \"sum\",\n \"filter\": {\n \"field\": \"Status\",\n \"equals\": \"Paid\"\n },\n \"groupBy\": \"Region\"\n}"
response = http.request(request)
puts response.read_body{
"fieldId": "<string>",
"operation": "sum",
"result": 123,
"groupedResults": [
{
"value": 123,
"groupValue": "<string>"
}
]
}Operations
| Operation | Description | Field requirement |
|---|---|---|
sum | Total of all values | Numeric field |
avg | Average of all values | Numeric field |
min | Smallest value | Any field |
max | Largest value | Any field |
count | Number of non-empty values | Any field |
count_distinct | Number of distinct values | Any field |
fieldId (a field ID or field name) is required for every operation. sum and avg require a numeric field (number, currency, percent, rating, or duration).Filtering
Use the optionalfilter to restrict which records are aggregated. It supports the same nested AND/OR logic as List Records.
Grouping
WhengroupBy is supplied, the response returns groupedResults (one entry per group with its value and groupValue) instead of a single result.
{
"fieldId": "Amount",
"operation": "sum",
"filter": { "field": "Status", "equals": "Paid" },
"groupBy": "Region"
}
Authorizations
Enter your Zite API key. Format: Bearer <api_key>
Path Parameters
The unique identifier of the database
The unique identifier of the table. You can also use the table name instead of the ID.
Body
The field to aggregate, specified by field ID or field name. Required for all operations. sum and avg require a numeric field (number, currency, percent, rating, or duration).
The aggregation to perform.
sum, avg, min, max, count, count_distinct Optional filter condition restricting which records are aggregated. Supports the same nested AND/OR logic as List Records.
Show child attributes
Show child attributes
Optional field (field ID or name) to group results by. When provided, groupedResults is returned instead of a single result.
Response
Aggregation result
The field ID that was aggregated.
The aggregation that was performed.
sum, avg, min, max, count, count_distinct The aggregated value. Null when groupBy is used (see groupedResults) or when no rows match. sum returns 0 when no rows match.
Present only when groupBy is supplied. One entry per group.
Show child attributes
Show child attributes
curl --request POST \
--url https://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/aggregate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"fieldId": "Amount",
"operation": "sum",
"filter": {
"field": "Status",
"equals": "Paid"
},
"groupBy": "Region"
}
'import requests
url = "https://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/aggregate"
payload = {
"fieldId": "Amount",
"operation": "sum",
"filter": {
"field": "Status",
"equals": "Paid"
},
"groupBy": "Region"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
fieldId: 'Amount',
operation: 'sum',
filter: {field: 'Status', equals: 'Paid'},
groupBy: 'Region'
})
};
fetch('https://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/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://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/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([
'fieldId' => 'Amount',
'operation' => 'sum',
'filter' => [
'field' => 'Status',
'equals' => 'Paid'
],
'groupBy' => 'Region'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/aggregate"
payload := strings.NewReader("{\n \"fieldId\": \"Amount\",\n \"operation\": \"sum\",\n \"filter\": {\n \"field\": \"Status\",\n \"equals\": \"Paid\"\n },\n \"groupBy\": \"Region\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/aggregate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"fieldId\": \"Amount\",\n \"operation\": \"sum\",\n \"filter\": {\n \"field\": \"Status\",\n \"equals\": \"Paid\"\n },\n \"groupBy\": \"Region\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/aggregate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"fieldId\": \"Amount\",\n \"operation\": \"sum\",\n \"filter\": {\n \"field\": \"Status\",\n \"equals\": \"Paid\"\n },\n \"groupBy\": \"Region\"\n}"
response = http.request(request)
puts response.read_body{
"fieldId": "<string>",
"operation": "sum",
"result": 123,
"groupedResults": [
{
"value": 123,
"groupValue": "<string>"
}
]
}