POST /entity/<type>/_summarize
post_entity_type_summarize
Counts without paging rows. One grouping returns a field's distinct values and their counts at ~300ms, so rank a shortlist with it and never scan every field.
API
Params
| part | value |
|---|---|
Content-Type |
the same vendor types _search requires |
filters |
same shape as _search |
summary_fields |
[{"field": "id", "type": "count"}] |
grouping |
[{"field": ..., "type": "exact", "direction": "asc"}]. Optional |
Sample requests
Grouped, which is the call worth making:
ARR = {"Content-Type": "application/vnd+shotgun.api3_array+json"}
r = c.post("/entity/versions/_summarize", headers=ARR,
json={"filters": [["project", "is", {"type": "Project", "id": 70}]],
"summary_fields": [{"field": "id", "type": "count"}],
"grouping": [{"field": "sg_status_list", "type": "exact", "direction": "asc"}]})
{
"data": {
"summaries": { "id": 100 },
"groups": [
{ "group_name": "na", "group_value": "na", "summaries": { "id": 28 } }
]
}
}
Ungrouped, where the whole body is 45 bytes:
r = c.post("/entity/versions/_summarize", headers=ARR,
json={"filters": [["project", "is", {"type": "Project", "id": 70}]],
"summary_fields": [{"field": "id", "type": "count"}]})
{ "summaries": { "id": 100 }, "groups": [] }
Response codes
| status | when |
|---|---|
| 200 | including for a field that cannot be summarized, where the body is near-empty |
Edge cases
- Summarizing an unsummarizable field,
image, answers 200 with a 37-byte body and no summary. It does not 400. Test that the key you asked for is insummariesbefore reading it. group_nameis the rendered label andgroup_valuethe raw one. For atimecodefield the rendered form isHH:MM:SS:FF, which is how the frame rate is recovered when no field exposes it.- One call per field at about 300ms. Over 71 fields that is 21 seconds. Rank a shortlist by fill rate first and summarize only the candidates.