POST /api/v3/datonis_query/thing_aggregated_data
Get aggregated thing stats like sum, count, min, max

Returns aggregated results for thing data for given thing keys

Params

Param name Description
thing_keys
optional

Array of sensor_keys


Value: Must be an array of any type
time_grouping
optional

type of time grouping i.e. month/day/hour/minute


Value: Must be a String
time_grouping_value
optional

integer representing value. e.g. if it is 15, and time_grouping is minute, data will be grouped in 15 minute intervals


Value: Must be Integer.
idle_time_required
optional

If idle time is required in the result


Value: Must be one of: <code>true</code>, <code>false</code>.
time_zone
optional

Time zone for calculating data`


Value: Must be a String
from
optional

From Date in format 'yyyy/mm/dd hh:mm:ss'


Value: Must be a String
to
optional

To Date in format 'yyyy/mm/dd hh:mm:ss'


Value: Must be a String
timestamp_format
optional

Format, int or str in which event timestamps should be returned


Value: Must be a String
metrics
optional

List of metric names required in the result.


Value: Must be an array of any type
data_format
optional

Format in which event data should be returned e.g. “array” , “map”


Value: Must be a String
pretty
optional

Return a pretty formatted response if true, Default is false


Value: Must be a Boolean

Examples

Request data for a thing for a period of 5 hours in Asia/Calcutta time zone.
  curl -X POST -H "Content-Type:application/json" --header 'X-Auth-Token:IEkmVGHsa4R3cGPw56MkfQ' -d '{"idle_time_required":true,"time_zone":"Asia/Calcutta","thing_keys":["11a6238e445dtd65a45ddfdabd6b8f41dbfetdfd"],"from":"2016/02/01 00:00:00","to":"2016/02/01 05:00:00" }' 'https://api.datonis.io/api/v3/datonis_query/thing_aggregated_data'

Returns a summary result and thing wise result.
{
  "summary_result": {
    "cpu": {
      "count": 498.0,
      "sum": 2028.144,
      "min": 0.046,
      "max": 7.988,
      "avg": 4.072578313253012,
      "idle_time_mins": 42,
      "total_time_mins": 300
    },
    "mem": {
      "count": 498.0,
      "sum": 124426.342,
      "min": 100.369,
      "max": 399.048,
      "avg": 249.85209236947793,
      "idle_time_mins": 42,
      "total_time_mins": 300
    }
  },
  "thing_wise_result": {
    "11a6238e445dtd65a45ddfdabd6b8f41dbfetdfd": {
      "cpu": {
        "count": 498.0,
        "sum": 2028.144,
        "min": 0.046,
        "max":...
Request data for a thing for a period of 3 hours in Asia/Calcutta time zone, grouped into hourly buckets.
  curl -X POST -H "Content-Type:application/json" --header 'X-Auth-Token:IEkmVGHsa4R3cGPw56MkfQ' -d '{"time_grouping":"hour","idle_time_required":true,"time_zone":"Asia/Calcutta","thing_keys":["11a6238e445dtd65a45ddfdabd6b8f41dbfetdfd"],"from":"2016/02/01 10:00:00","to":"2016/02/01 13:00:00" }' 'https://api.datonis.io/api/v3/datonis_query/thing_aggregated_data'

Returns a summary result, thing wise result and a hourly time grouped result for the thing.
{
  "summary_result": {
    "cpu": {
      "count": 634.0,
      "sum": 2532.3750000000005,
      "min": 0.004,
      "max": 7.996,
      "avg": 3.9942823343848586,
      "idle_time_mins": 4,
      "total_time_mins": 180
    },
    "mem": {
      "count": 634.0,
      "sum": 158742.0,
      "min": 100.343,
      "max": 399.703,
      "avg": 250.38170347003154,
      "idle_time_mins": 4,
      "total_time_mins": 180
    }
  },
  "thing_wise_result": {
    "11a6238e445dtd65a45ddfdabd6b8f41dbfetdfd": {
      "cpu": {
        "count": 634.0,
        "sum": 2532.3750000000005,
        "min": 0.004,
 ...
Request data for a thing for 10 minute period in UTC time zone, grouped in minutely buckets.
  curl -X POST -H "Content-Type:application/json" --header 'X-Auth-Token:IEkmVGHsa4R3cGPw56MkfQ' -d '{"time_grouping":"minute","idle_time_required":true,"time_zone":"UTC","thing_keys":["e4aa3e35t675fc57ce81f3dd6e2dcdef492at4f7"],"date_ranges":[{"from":"2015/04/02 17:05:00","to":"2015/04/02 17:15:00"}]}' 'https://api.datonis.io/api/v3/datonis_query/thing_aggregated_data'

Returns a summary result, thing wise result and a minutely  time grouped result for the thing.
{
  "summary_result": {
    "cpu": {
      "count": 32.0,
      "sum": 113.804,
      "min": 0.095,
      "max": 7.894,
      "avg": 3.556375,
      "idle_time_mins": 0,
      "total_time_mins": 10
    },
    "mem": {
      "count": 32.0,
      "sum": 7925.794999999999,
      "min": 107.754,
      "max": 399.647,
      "avg": 247.68109374999997,
      "idle_time_mins": 0,
      "total_time_mins": 10
    }
  },
  "thing_wise_result": {
    "11a6238e445dtd65a45ddfdabd6b8f41dbfetdfd": {
      "cpu": {
        "count": 32.0,
        "sum": 113.804,
        "min": 0.095,
        "max": 7.894,
       ...
Request data for a thing for 1 hour for the 'cpu' field only.
  curl -X POST -H "Content-Type:application/json" --header 'X-Auth-Token:IEkmVGHsa4R3cGPw56MkfQ' -d '{"idle_time_required":true,"time_zone":"Asia/Calcutta","thing_keys":["11a6238e445dtd65a45ddfdabd6b8f41dbfetdfd"],"from":"2016/02/01 10:00:00","to":"2016/02/01 11:00:00", "metrics":["cpu"] }' 'https://api.datonis.io/api/v3/datonis_query/thing_aggregated_data'

Returns one hour of aggregated data for 'cpu' field
{
  "summary_result": {
    "cpu": {
      "count": 35.0,
      "sum": 124.828,
      "min": 0.095,
      "max": 7.894,
      "avg": 3.5665142857142857,
      "idle_time_mins": 0,
      "total_time_mins": 11
    }
  },
  "thing_wise_result": {
    "11a6238e445dtd65a45ddfdabd6b8f41dbfetdfd": {
      "cpu": {
        "count": 35.0,
        "sum": 124.828,
        "min": 0.095,
        "max": 7.894,
        "avg": 3.5665142857142857,
        "idle_time_mins": 0,
        "total_time_mins": 11
      }
    }
  }
}

POST /api/v3/datonis_query/thing_data
Get raw event data for a thing

Returns raw event data for a thing

Params

Param name Description
thing_key
optional

Thing key


Value: Must be a String
from
optional

From Date in format 'yyyy/mm/dd hh:mm:ss'


Value: Must be a String
to
optional

To Date in format 'yyyy/mm/dd hh:mm:ss'


Value: Must be a String
page
optional

Page number of results to be fetched


Value: Must be Integer.
per
optional

Number of records to be returnes in one page


Value: Must be Integer.
timestamp_format
optional

Format, int or str in which event timestamps should be returned


Value: Must be a String
time_zone
optional

time zone in which to return data e.g. “Mumbai”, “EST” etc


Value: Must be a String
order
optional

Order of time_stamp, asc or desc, in which events will be filtered


Value: Must be a String
metrics
optional

List of fields required in the result.


Value: Must be an array of any type
data_format
optional

Format in which event data should be returned e.g. “array” , “map”


Value: Must be a String
pretty
optional

Return a pretty formatted response if true, Default is false


Value: Must be a Boolean

Examples

Request raw data for a thing for a period of 5 minutes in time zone Mumbai with 10 events per page.
  curl -X POST -H "Content-Type:application/json" --header 'X-Auth-Token:IEkmVGHsa4R3cGPw56MkfQ' -d '{"thing_key":"11a6238e445dtd65a45ddfdabd6b8f41dbfetdfd", "from":"2016/02/02 17:05:00", "to":"2016/02/02 17:10:00", "time_zone":"Mumbai" , "time_format":"str", "per":"10"}' 'https://api.datonis.io/api/v3/datonis_query/thing_data'

Returns upto 10 events.
{
  "11a6238e445dtd65a45ddfdabd6b8f41dbfetdfd": {
    "total_event_count": 22,
    "page_number": "1",
    "event_data": [
      {
        "timestamp": "2016/02/02 17:09:53",
        "data": {
          "mem": 171.573,
          "cpu": 1.365
        }
      },
      {
        "timestamp": "2016/02/02 17:09:36",
        "data": {
          "mem": 172.742,
          "cpu": 7.427
        }
      },
      {
        "timestamp": "2016/02/02 17:09:07",
        "data": {
          "mem": 302.88,
          "cpu": 6.717
        }
      },
      {
        "timestamp": "2016/02/02 17:08:30",
       ...
Request page no 2 of raw data for a thing for a period of 5 minutes in time zone Mumbai with 10 events per page.
  curl -X POST -H "Content-Type:application/json" --header 'X-Auth-Token:IEkmVGHsa4R3cGPw56MkfQ' -d '{"thing_key":"11a6238e445dtd65a45ddfdabd6b8f41dbfetdfd", "from":"2016/02/02 17:05:00", "to":"2016/02/02 17:10:00", "time_zone":"Mumbai" , "time_format":"str", "per":10, "page":2}' 'https://api.datonis.io/api/v3/datonis_query/thing_data'

Return data for page no 2.
{
  "11a6238e445dtd65a45ddfdabd6b8f41dbfetdfd": {
    "total_event_count": 22,
    "page_number": "2",
    "event_data": [
      {
        "timestamp": "2016/02/02 17:07:01",
        "data": {
          "cpu": 0.463,
          "mem": 159.714
        }
      },
      {
        "timestamp": "2016/02/02 17:06:56",
        "data": {
          "mem": 192.217,
          "cpu": 0.613
        }
      },
      {
        "timestamp": "2016/02/02 17:06:55",
        "data": {
          "cpu": 0.099,
          "mem": 161.124
        }
      },
      {
        "timestamp": "2016/02/02 17:06:42",
       ...
Request raw data where time is returned in integer format (seconds after epoch)
  curl -X POST -H "Content-Type:application/json" --header 'X-Auth-Token:IEkmVGHsa4R3cGPw56MkfQ' -d '{"thing_key":"11a6238e445dtd65a45ddfdabd6b8f41dbfetdfd", "from":"2016/02/02 17:05:00", "to":"2016/02/02 17:10:00", "time_zone":"Mumbai" , "time_format":"int", "per":10, "page":2}' 'https://api.datonis.io/api/v3/datonis_query/thing_data'

Returns data with timestamps in integer form.
{
  "11a6238e445dtd65a45ddfdabd6b8f41dbfetdfd": {
    "total_event_count": 22,
    "page_number": "2",
    "event_data": [
      {
        "timestamp": 1454413021,
        "data": {
          "cpu": 0.463,
          "mem": 159.714
        }
      },
      {
        "timestamp": 1454413016,
        "data": {
          "mem": 192.217,
          "cpu": 0.613
        }
      },
      {
        "timestamp": 1454413015,
        "data": {
          "cpu": 0.099,
          "mem": 161.124
        }
      },
      {
        "timestamp": 1454413002,
        "data": {
          "cpu": 5.308,
         ...
Request raw data only for 'cpu' field.
  curl -X POST -H "Content-Type:application/json" --header 'X-Auth-Token:IEkmVGHsa4R3cGPw56MkfQ' -d '{"thing_key":"e4aa3e35t675fc57ce81f3dd6e2dcdef492at4f7", "from":"2015/04/02 17:05:00", "to":"2015/04/02 17:10:00", "time_zone":"Mumbai" , "time_format":"int", "per":"10", "page":"1", "metrics":["cpu"]}' 'https://api.datonis.io/api/v3/datonis_query/thing_data'

Return data with only the required fields.
{
  "e4aa3e35t675fc57ce81f3dd6e2dcdef492at4f7": {
    "total_event_count": 30,
    "page_number": "1",
    "event_data": [
      {
        "data": {
          "cpu": 1.3250000000000002
        },
        "time_stamp": 1427974799
      },
      {
        "data": {
          "cpu": 1.45
        },
        "time_stamp": 1427974797
      },
      {
        "data": {
          "cpu": 1.45
        },
        "time_stamp": 1427974795
      },
      {
        "data": {
          "cpu": 1.45
        },
        "time_stamp": 1427974794
      },
      {
        "data": {
          "cpu": 1.35
        },
  ...