Timeseries

The Sensor collection manages Sensors for Locations associated with the DataService. Sensor access is restricted to Central Service Users with permissions for the Sensor and to the Admin who owns the Sensor.

Post Timeseries Datapoints

This stores datapoints in the timeseries of the specified Sensorpoint.

The first datapoint that is posted to the uuid defines the datatype for all further timeseries datapoints e.g. if the first datapoint posted to a certain uuid is a int then all further datapoints have to be ints.

Example request:

POST /api/sensor/timeseries HTTP/1.1
Accept: application/json; charset=utf-8

{ "data":     [
                  {
                    "sensor_id":"a5d6277e-4b51-4056-b9fd-0a6505b4f5a6",
                    "samples":[
                            {
                              "value":24.56,
                              "time":1225865462
                            },
                            {
                              "value":23.12,
                              "time":1225865500
                            }
                           ]
                  },
                  {
                    "sensor_id":"cee06227-72e5-49d2-94f1-20c501ca2afa",
                    "samples":[
                            {
                              "value":24.56,
                              "time":1225865462
                            },
                            {
                              "value":23.12,
                              "time":1225865500
                            }
                           ]
                  }
                ]
  }

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "True"
}

Read Timeseries Datapoints

This retreives a list of datapoints for the timeseries of the specified Sensorpoint

Note: Both interval and resolution are specified with the time value appended by the type of the value e.g. 10s for 10 seconds or 10m for 10 minutes.

Example request:

GET /sensor/<sensor-uuid>/timeseries?start_time=1445535722&end_time=1445789516&resolution=10s HTTP/1.1
Accept: application/json; charset=utf-8

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success":"True",
  "data": {
    "series": [
      {
        "columns": [
          "time",
          "inserted_at",
          "value"
        ],
        "name": "35b137b2-c7c6-4608-8489-1c3f0ee7e2d5",
        "values": [
          [
            "2015-10-22T17:41:44.762495917Z",
            1445535722.0,
            22.11
          ],
          [
            "2015-10-22T17:43:19.48927063Z",
            1445535818.0,
            22.23
          ],
                    [
            "2015-10-22T22:44:53.066248715Z",
            1445553913.0,
            24.56
          ]
        ]
      }
    ]
  }
}