Aggregate
A definition for an automated data agregate calculation based on datapoints.
POST Create aggregate
Create a new aggregate.
POST aggregates
Optional parameters
Name /type | Description /example | Constraints |
|---|---|---|
_id | The unique aggregate identifier "rollupDatapoints-0C97-4378-F4DA-A1FD-7353-EFBB-B379-9CBD-4B78-1927-44D2-790D-25BA-A086-BCEC-0D93" |
|
build_at | When this aggregate is scheduled to be built "2017-05-28T09:50:23.106Z" |
|
build_every | How often this aggregate should be automatically rebuilt "1_d" |
|
description | Text describing this document "Blue Oak Ranch daily cumulative precipitation." | |
expires_at | When this aggregate definition is scheduled to be groomed "2017-05-28T09:50:23.106Z" |
|
method | The aggregation method to invoke when building the aggregate "rollupDatapoints" | |
name | "Daily Cumulative Precipitation" | |
spec | A unique user-provided specification passed to the aggregation method {
"big_math": true,
"query": {
"datastream_id": "5ae879c9fe27f428ce102df9",
"time_local": true
},
"rollups": [
{
"aggregations": [
{
"alias": "v_sum",
"field": "v",
"filter": "optional",
"func": "sum"
}
],
"window": "1_h"
}
],
"shift": "so_M",
"time_cursor": "1_d",
"time_gte": "2017-01-01",
"time_lt": "2018-01-01"
} |
cURL
curl -X POST "http://api.dendra.science/v1/aggregates" \
-H "Content-Type: application/json" \
--data '{"_id":"rollupDatapoints-0C97-4378-F4DA-A1FD-7353-EFBB-B379-9CBD-4B78-1927-44D2-790D-25BA-A086-BCEC-0D93","build_at":"2017-05-28T09:50:23.106Z","build_every":"1_d","description":"Blue Oak Ranch daily cumulative precipitation.","expires_at":"2017-05-28T09:50:23.106Z","method":"rollupDatapoints","name":"Daily Cumulative Precipitation","spec":{"big_math":true,"query":{"datastream_id":"5ae879c9fe27f428ce102df9","time_local":true},"rollups":[{"aggregations":[{"alias":"v_sum","field":"v","filter":"optional","func":"sum"}],"window":"1_h"}],"shift":"so_M","time_cursor":"1_d","time_gte":"2017-01-01","time_lt":"2018-01-01"}}'Response
{}DELETE Remove aggregate
Remove an existing aggregate.
DELETE aggregates/:_id
cURL
curl -X DELETE "http://api.dendra.science/v1/aggregates/rollupDatapoints-0C97-4378-F4DA-A1FD-7353-EFBB-B379-9CBD-4B78-1927-44D2-790D-25BA-A086-BCEC-0D93" \
-H "Content-Type: application/json"Response
{}GET Aggregate info
Return a specific aggregate.
GET aggregates/:_id
cURL
curl -X GET "http://api.dendra.science/v1/aggregates/rollupDatapoints-0C97-4378-F4DA-A1FD-7353-EFBB-B379-9CBD-4B78-1927-44D2-790D-25BA-A086-BCEC-0D93" \
-H "Content-Type: application/json"Response
{}GET List aggregates
Find one or more aggregates based on the query parameters.
GET aggregates
Optional parameters
Name /type | Description /example | Constraints |
|---|---|---|
field_name | Filter where a field is equal to the supplied value "field_value" | |
field_name[$op] | Filter using advanced query operators: $in, $nin, $lt, $lte, $gt, $gte, $ne, and $or "field_value" | |
$limit | Specify the maximum number of items to return 10 |
|
$skip | Specify the number of items to skip over (offset) 2 |
|
$sort[field_name] | Specify the fields to sort by and the respective sort order 1 |
|
$select[field_name] | Pick which fields to include in the results 1 |
|
cURL
curl -X GET "http://api.dendra.science/v1/aggregates?field_name=field_value&field_name[$op]=field_value&$limit=10&$skip=2&$sort[field_name]=1&$select[field_name]=1" \
-H "Content-Type: application/json"Response
{
"total": 1,
"limit": 10,
"skip": 2,
"data": [
{}
]
}POST Request aggregate
Request an aggregate result. Creates and builds the aggregate if it does not exist.
POST aggregates/request
Optional parameters
Name /type | Description /example | Constraints |
|---|---|---|
build_at | When this aggregate is scheduled to be built "2017-05-28T09:50:23.106Z" |
|
build_every | How often this aggregate should be automatically rebuilt "1_d" |
|
description | Text describing this document "Blue Oak Ranch daily cumulative precipitation." | |
expires_at | When this aggregate definition is scheduled to be groomed "2017-05-28T09:50:23.106Z" |
|
method | The aggregation method to invoke when building the aggregate "rollupDatapoints" | |
name | "Daily Cumulative Precipitation" | |
spec | A unique user-provided specification passed to the aggregation method {
"big_math": true,
"query": {
"datastream_id": "5ae879c9fe27f428ce102df9",
"time_local": true
},
"rollups": [
{
"aggregations": [
{
"alias": "v_sum",
"field": "v",
"filter": "optional",
"func": "sum"
}
],
"window": "1_h"
}
],
"shift": "so_M",
"time_cursor": "1_d",
"time_gte": "2017-01-01",
"time_lt": "2018-01-01"
} |
cURL
curl -X POST "http://api.dendra.science/v1/aggregates/request" \
-H "Content-Type: application/json" \
--data '{"build_at":"2017-05-28T09:50:23.106Z","build_every":"1_d","description":"Blue Oak Ranch daily cumulative precipitation.","expires_at":"2017-05-28T09:50:23.106Z","method":"rollupDatapoints","name":"Daily Cumulative Precipitation","spec":{"big_math":true,"query":{"datastream_id":"5ae879c9fe27f428ce102df9","time_local":true},"rollups":[{"aggregations":[{"alias":"v_sum","field":"v","filter":"optional","func":"sum"}],"window":"1_h"}],"shift":"so_M","time_cursor":"1_d","time_gte":"2017-01-01","time_lt":"2018-01-01"}}'Response
{}GET Aggregate result
Request a specific pre-built aggregate result.
GET aggregates/result/:_id
cURL
curl -X GET "http://api.dendra.science/v1/aggregates/result/rollupDatapoints-0C97-4378-F4DA-A1FD-7353-EFBB-B379-9CBD-4B78-1927-44D2-790D-25BA-A086-BCEC-0D93" \
-H "Content-Type: application/json"Response
{
"request": {
"_id": "rollupDatapoints-0C97-4378-F4DA-A1FD-7353-EFBB-B379-9CBD-4B78-1927-44D2-790D-25BA-A086-BCEC-0D93",
"created_at": "2017-05-28T09:50:23.106Z",
"updated_at": "2017-05-28T09:50:23.106Z",
"build_at": "2017-05-28T09:50:23.106Z",
"build_every": "1_d",
"build_info": {
"request_subject": "dendra.aggregateBuild.v1.req",
"requested_at": "2017-05-11T00:00:00Z"
},
"description": "Blue Oak Ranch daily cumulative precipitation.",
"expires_at": "2017-05-28T09:50:23.106Z",
"method": "rollupDatapoints",
"name": "Daily Cumulative Precipitation",
"spec": {
"big_math": true,
"query": {
"datastream_id": "5ae879c9fe27f428ce102df9",
"time_local": true
},
"rollups": [
{
"aggregations": [
{
"alias": "v_sum",
"field": "v",
"filter": "optional",
"func": "sum"
}
],
"window": "1_h"
}
],
"shift": "so_M",
"time_cursor": "1_d",
"time_gte": "2017-01-01",
"time_lt": "2018-01-01"
}
},
"result": {
"build_info": {
"duration": 13336,
"finished_at": "2018-06-25T18:49:43.705Z",
"started_at": "2018-06-25T18:49:30.369Z"
},
"data": []
}
}