Aggregates#
/objects/{objectSlug}/records/aggregatesCalculates over every record that matches, not just one page.
| Parameter | Meaning |
|---|---|
aggregates | A JSON array of up to 20 { "fieldId": "…", "operation": "…" }. |
filters, search, deleted | As in List records. |
groupByFieldId | Optional ID of a Select field. Results come back for each of its options. |
| Field type | Operations |
|---|---|
Any except relation | count, count_empty, count_not_empty, count_unique, percent_empty, percent_not_empty |
number, currency | also sum, avg, min, max |
date, date_time | also earliest, latest |
checkbox | also count_true, count_false |
relation | count only |
Results are keyed by field ID, so ask for one operation per field in a request. If you repeat a field, only one result comes back.
curl --fail-with-body -G "$JEMERO_URL/objects/companies/records/aggregates" \
-H "Authorization: Bearer $JEMERO_API_KEY" \
--data-urlencode "aggregates=[{\"fieldId\":\"$REVENUE_FIELD_ID\",\"operation\":\"sum\"}]"const aggregates = [{ fieldId: process.env.REVENUE_FIELD_ID, operation: 'sum' }];
const url = new URL(`${process.env.JEMERO_URL}/objects/companies/records/aggregates`);
url.search = new URLSearchParams({ aggregates: JSON.stringify(aggregates) });
const response = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.JEMERO_API_KEY}` },
});
if (!response.ok) throw new Error(`${response.status} ${await response.text()}`);
console.log((await response.json()).values);import json
import os
import requests
aggregates = [{"fieldId": os.environ["REVENUE_FIELD_ID"], "operation": "sum"}]
response = requests.get(
f"{os.environ['JEMERO_URL']}/objects/companies/records/aggregates",
headers={"Authorization": f"Bearer {os.environ['JEMERO_API_KEY']}"},
params={"aggregates": json.dumps(aggregates)},
timeout=30,
)
response.raise_for_status()
print(response.json()["values"]){ "values": { "11a499d0-f2b7-493d-8bbd-bc709271e0e1": 125000000 } }With groupByFieldId, the answer is keyed by option ID. Records with no option, or one that was removed, are under __none__. Empty groups are left out.
{
"groups": {
"dae82246-2e36-455a-8a9b-a406ca34f04e": {
"11a499d0-f2b7-493d-8bbd-bc709271e0e1": 125000000
}
}
}A calculation on a field that is hidden from your role is left out. A calculation that has no records to work on can be null.
Grouped lists#
/objects/{objectSlug}/records/groupsReturns the first page of several filtered groups in one request, such as the columns of a board.
| Parameter | Meaning |
|---|---|
groups | Required. A JSON array of 1–60 { "filters": [...] }. |
filters | Conditions applied to every group, as well as its own. |
search, sorts, pageSize | As in List records. |
curl --fail-with-body -G "$JEMERO_URL/objects/companies/records/groups" \
-H "Authorization: Bearer $JEMERO_API_KEY" \
--data-urlencode "pageSize=5" \
--data-urlencode "groups=[{\"filters\":[{\"fieldId\":\"$NAME_FIELD_ID\",\"operator\":\"contains\",\"value\":\"glob\"}]},{\"filters\":[{\"fieldId\":\"$NAME_FIELD_ID\",\"operator\":\"contains\",\"value\":\"labs\"}]}]"{
"groups": [
{ "records": [], "total": 0, "totalIsCapped": false }
]
}Groups come back in the order you sent them. Only the first page of each is returned. To read more of a group, use List records with the same filters. This endpoint covers live records only.
Errors#
| Status | Cause |
|---|---|
400 | Invalid JSON, an unknown field, an operation the field type doesn't offer, or groupByFieldId isn't a Select field. |
404 Object not found | No object with that slug. |