Search documentation
karat

+

K

User Documentation ↗

Aggregate Objects

POST/api/v1/ontologies/{ontologyRid}/objects/{objectType}/aggregate

Perform functions on object fields in the specified ontology and object type.

Third-party applications using this endpoint via OAuth2 must request the following operation scope: api:ontologies-read.

Path parameters

ontologyRid
string

The unique Resource Identifier (RID) of the Ontology that contains the objects.

objectType
string

The type of the object to aggregate on.

Request body

AggregateObjectsRequest
object
Hide child attributes

Hide child attributes

aggregation
list<Aggregation>
optional
Show child attributes

Show child attributes

query
union
optional
Show child attributes

Show child attributes

groupBy
list<AggregationGroupBy>
optional
Show child attributes

Show child attributes

Response body

AggregateObjectsResponse
object

Success response.

Hide child attributes

Hide child attributes

excludedItems
integer
optional
nextPageToken
string
optional

The page token indicates where to start paging. This should be omitted from the first page's request. To fetch the next page, clients should take the value from the nextPageToken field of the previous response and use it to populate the pageToken field of the next request.

data
list<AggregateObjectsResponseItem>
optional
Show child attributes

Show child attributes

Examples

Request

Copied!
1 2 3 4 5 curl -X POST \ -H "Content-type: application/json" \ -H "Authorization: Bearer $TOKEN" \ "https://$HOSTNAME/api/v1/ontologies/ri.ontology.main.ontology.c61d9ab5-2919-4127-a0a1-ac64c0ce6367/objects/employee/aggregate" \ -d '{"aggregation":[{"type":"min","field":"properties.tenure","name":"min_tenure"},{"type":"avg","field":"properties.tenure","name":"avg_tenure"}],"query":{"not":{"field":"properties.name","eq":"john"}},"groupBy":[{"field":"properties.startDate","type":"range","ranges":[{"gte":"2020-01-01","lt":"2020-06-01"}]},{"field":"properties.city","type":"exact"}]}'

Response

Copied!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 { "data": [ { "metrics": [ { "name": "min_tenure", "value": 1 }, { "name": "avg_tenure", "value": 3 } ], "group": { "properties.startDate": { "gte": "2020-01-01", "lt": "2020-06-01" }, "properties.city": "New York City" } }, { "metrics": [ { "name": "min_tenure", "value": 2 }, { "name": "avg_tenure", "value": 3 } ], "group": { "properties.startDate": { "gte": "2020-01-01", "lt": "2020-06-01" }, "properties.city": "San Francisco" } } ] }