Records

Count records per group

One SQL GROUP BY returning every bucket's exact count — the split a board column header or a summary tile needs, without reading the records themselves. fieldSlug must name a select or checkbox field: their stored value IS the grouping key, so the buckets are exactly the ones a client would build. Grouping by a text, number or date field is rejected rather than approximated (text keys are truncated at the projection limit; date keys would bucket by the server's timezone, not the viewer's). viewId and filters narrow the set first, with the same exactness rules as records.count: provably-exact conditions stay a cheap SQL aggregate, anything else falls back to evaluating every matching row server-side — exact, but not free on a large Base. Groups come back keyed by raw choice id (or "true"/"false"), with null for records that have no value; labels are the client's to render.

get/api/v1/records/group-by

Request

  • Base URL: https://api-docs.busabase.com
  • URL: https://api-docs.busabase.com/api/v1/records/group-by
  • Auth: none declared

Query parameters

baseIdstring required

Required: a field slug is only unambiguous within one Base.

fieldSlugstring

The field to group by. OMIT it to aggregate the whole filtered set as a single bucket, which is what a summary tile wants. Under the default grid bucketing only select and checkbox can be grouped; sql bucketing also allows number and date fields.

bucketing'grid' | 'sql'

How records are bucketed, and the two modes disagree on real data. grid (default) buckets the way the grid renders: an unset checkbox counts as false and an empty string falls in the null bucket — right for a Kanban column header. sql buckets the way GROUP BY does: a missing value gets its OWN bucket and nothing is folded — right for anything reproducing SQL. sql also returns keys in their own type (a number for a number field) rather than as strings.

fn'sum' | 'avg' | 'min' | 'max' | 'count' required
fieldSlugstring required
viewIdstring

Group only what this saved View would display. Its filters apply; its sort is ignored.

fieldSlugstring required
fieldTypestring
operator'contains' | 'equals' | 'not_empty' | 'is_empty' | 'is_true' | 'is_false' required
valueunknown

Response

Every group's exact count, plus the total across all groups. Groups with zero records are omitted — a Base's full choice list lives in its field definition, so the client already knows which buckets to render empty.

totalinteger required

Changes

No recorded changes to this operation across all 1 revision of this API.