Skip to content

REST API

Aggregation

Almost every listing in the REST API has an /aggregate sub-route that answers with numbers instead of records. Use it to count, sum or average without fetching every page. This article explains its parameters and its response.

The sub-route sits next to the listing, for example GET /api/rest/v1/units/aggregate and GET /api/rest/v1/sites/{site_id}/units/aggregate. It needs the same permission as the listing and takes the same q filters, so a filter narrows a listing and its aggregate in the same way. Webhook endpoints are the exception: their listing has no aggregate.

  • aggregate: what to compute. count is the default. sum:<field>, avg:<field>, min:<field> and max:<field> work on numeric fields, for example sum:base_area on units.
  • group_by: optional. Either a field such as state, unit_type or site_id, or a time field and a bucket separated by a colon, such as requested_at:day.
  • range_from, range_to: optional, only with a time bucket. They limit the data to the window and fill empty buckets inside it, so every day appears even where nothing happened. Both ends are inclusive. Either may be given alone. Send them as ISO 8601 times with an offset, as described in Time and time zones.

Buckets that place a moment on the calendar are hour, day, week, month, quarter and year. Buckets that collapse to a part of the time are hour_of_day, day_of_week, day_of_month and month_of_year. Each aggregate route lists in the REST API reference which fields it groups and aggregates on.

Count the interaction requests per day in one week:

Terminal window
curl -g "$SEDISTO_HOST/api/rest/v1/interaction_requests/aggregate?group_by=requested_at:day&range_from=2026-10-01T00:00:00%2B02:00&range_to=2026-10-07T23:59:59%2B02:00" \
-H "Authorization: Bearer $SEDISTO_TOKEN"
{
"aggregate": "count",
"group_by": "requested_at:day",
"groups": [
{ "label": "2026-10-01", "value": 112 },
{ "label": "2026-10-02", "value": 98 }
],
"total_groups": 7,
"time_zone": "Berlin"
}

Without group_by the response carries a single value instead of groups. For count it is 0 when nothing matches; for the other functions it is null.

Labels are always strings in stable English: dates such as 2026-10-01, 2026-Q4 for quarters, monday or january for parts of the time. A site_id group is labelled with the site’s name.

Time buckets are cut in the site’s time zone when the request reaches sites in exactly one time zone, and in UTC otherwise. The response names the zone in time_zone. For week and day_of_week it also names the first day of the week in week_start, derived from the sites’ countries.

A grouping with more than 200 groups is refused with 400 rather than shortened. Every refusal carries a reason, such as unknown_group_by, bucket_required or too_many_groups. See Errors.