Records
Aggregate Records
Compute a sum, average, min, max, or count over a field, optionally filtered and grouped.
POST
/
bases
/
{databaseId}
/
tables
/
{tableId}
/
records
/
aggregate
Aggregate records
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": "fjshKDyc3Ni",
"operation": "sum",
"filter": {
"field": "Status",
"equals": "Paid"
},
"groupBy": "foPtn5EpNf8"
}
'import requests
url = "https://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/aggregate"
payload = {
"fieldId": "fjshKDyc3Ni",
"operation": "sum",
"filter": {
"field": "Status",
"equals": "Paid"
},
"groupBy": "foPtn5EpNf8"
}
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: 'fjshKDyc3Ni',
operation: 'sum',
filter: {field: 'Status', equals: 'Paid'},
groupBy: 'foPtn5EpNf8'
})
};
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' => 'fjshKDyc3Ni',
'operation' => 'sum',
'filter' => [
'field' => 'Status',
'equals' => 'Paid'
],
'groupBy' => 'foPtn5EpNf8'
]),
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\": \"fjshKDyc3Ni\",\n \"operation\": \"sum\",\n \"filter\": {\n \"field\": \"Status\",\n \"equals\": \"Paid\"\n },\n \"groupBy\": \"foPtn5EpNf8\"\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\": \"fjshKDyc3Ni\",\n \"operation\": \"sum\",\n \"filter\": {\n \"field\": \"Status\",\n \"equals\": \"Paid\"\n },\n \"groupBy\": \"foPtn5EpNf8\"\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\": \"fjshKDyc3Ni\",\n \"operation\": \"sum\",\n \"filter\": {\n \"field\": \"Status\",\n \"equals\": \"Paid\"\n },\n \"groupBy\": \"foPtn5EpNf8\"\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 | Numeric or date field |
max | Largest value | Numeric or date field |
count | Number of non-empty values | Any field |
count_distinct | Number of distinct values | Any field |
fieldId is required for every operation. It and groupBy take field IDs: field names aren’t accepted. sum and avg require a numeric field (number, currency, percent, rating, or duration). min and max on a date field return epoch milliseconds.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) and result is null. For a select field, groupValue is the option ID, not its label.
{
"fieldId": "fjshKDyc3Ni",
"operation": "sum",
"filter": { "field": "Status", "equals": "Paid" },
"groupBy": "foPtn5EpNf8"
}
Path Parameters
Body
application/json
Response
Aggregation result
⌘I
Aggregate records
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": "fjshKDyc3Ni",
"operation": "sum",
"filter": {
"field": "Status",
"equals": "Paid"
},
"groupBy": "foPtn5EpNf8"
}
'import requests
url = "https://tables.zite.com/api/v1/bases/{databaseId}/tables/{tableId}/records/aggregate"
payload = {
"fieldId": "fjshKDyc3Ni",
"operation": "sum",
"filter": {
"field": "Status",
"equals": "Paid"
},
"groupBy": "foPtn5EpNf8"
}
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: 'fjshKDyc3Ni',
operation: 'sum',
filter: {field: 'Status', equals: 'Paid'},
groupBy: 'foPtn5EpNf8'
})
};
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' => 'fjshKDyc3Ni',
'operation' => 'sum',
'filter' => [
'field' => 'Status',
'equals' => 'Paid'
],
'groupBy' => 'foPtn5EpNf8'
]),
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\": \"fjshKDyc3Ni\",\n \"operation\": \"sum\",\n \"filter\": {\n \"field\": \"Status\",\n \"equals\": \"Paid\"\n },\n \"groupBy\": \"foPtn5EpNf8\"\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\": \"fjshKDyc3Ni\",\n \"operation\": \"sum\",\n \"filter\": {\n \"field\": \"Status\",\n \"equals\": \"Paid\"\n },\n \"groupBy\": \"foPtn5EpNf8\"\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\": \"fjshKDyc3Ni\",\n \"operation\": \"sum\",\n \"filter\": {\n \"field\": \"Status\",\n \"equals\": \"Paid\"\n },\n \"groupBy\": \"foPtn5EpNf8\"\n}"
response = http.request(request)
puts response.read_body{
"fieldId": "<string>",
"operation": "sum",
"result": 123,
"groupedResults": [
{
"value": 123,
"groupValue": "<string>"
}
]
}