Back to top

History

The raw data stored in the STH can be consumed in the following ways:

Resource Group

Filter data by last N values of an attribute

This path gets the last N values of the attributes’ history. Also, another attributes can be passed as: &attr=attr1,attr2,…,attrN

Filter by last N values and attribute
GET/device/{device_id}/history?lastN={lastN}&attr={attr}

Example URI

GET http://localhost:8000/device/labtemp/history?lastN=3&attr=temperature
URI Parameters
HideShow
device_id
string (required) Example: labtemp

Identifier of the entity whose associated raw data wants to be retrieved.

attr
string (required) Example: temperature

Name of the attribute whose associated raw data wants to be retrieved.

lastN
number (optional) Default: 1 Example: 3

Last number of values for this attribute (attr)

Request
HideShow
Headers
Content-Type: application/json
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json; charset=UTF-8
Body
[
  {
    "device_id": "labtemp",
    "ts": "2014-02-14T13:43:33.306Z",
    "value": "22.12",
    "attr": "temperature"
  },
  {
    "device_id": "labtemp",
    "ts": "2014-02-14T13:42:33.306Z",
    "value": "23.12",
    "attr": "temperature"
  },
  {
    "device_id": "labtemp",
    "ts": "2014-02-14T13:41:33.306Z",
    "value": "24.10",
    "attr": "temperature"
  }
]

Retrieves all data from history

This path will retrieve all data from all device’s attributes, unless a parameter is given.

Retrieve all data from device
GET/device/{device_id}/history

Example URI

GET http://localhost:8000/device/labtemp/history
URI Parameters
HideShow
device_id
string (required) Example: labtemp

Identifier of the entity whose associated raw data wants to be retrieved.

attr
string (optional) Example: none

Name of the attribute whose associated raw data wants to be retrieved. If not provided, will consider all attributes.

lastN
number (optional) Example: none

Maximum number of raw data entries to retrieve. If not provided, will return all data entries of the attributes.

dateFrom
date (optional) Example: none

The starting date from which the raw data should be retrieved. If not provided, the origin of time is used.

dateTo
date (optional) Example: none

The final date until which the raw data should be retrieved. If not provided, the current date is used.

Request
HideShow
Headers
Content-Type: application/json
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json; charset=UTF-8
Body
{
  "protocol": [],
  "temperature": [
    {
      "device_id": "labtemp",
      "ts": "2014-02-14T13:43:33.306Z",
      "value": "22.12",
      "attr": "temperature"
    },
    {
      "device_id": "labtemp",
      "ts": "2014-02-14T13:42:33.306Z",
      "value": "22.12",
      "attr": "temperature"
    },
    {
      "device_id": "labtemp",
      "ts": "2014-02-14T13:41:33.306Z",
      "value": "22.12",
      "attr": "temperature"
    },
    {
      "device_id": "labtemp",
      "ts": "2014-02-14T13:40:33.306Z",
      "value": "22.12",
      "attr": "temperature"
    },
    {
      "device_id": "labtemp",
      "ts": "2014-02-14T13:39:33.306Z",
      "value": "22.12",
      "attr": "temperature"
    },
    {
      "device_id": "labtemp",
      "ts": "2014-02-14T13:38:33.306Z",
      "value": "22.12",
      "attr": "temperature"
    }
  ]
}

Filtering by offset and limit

Gets the raw data stored by the STH from certain date onwards (or the origin of time if no starting date is provided) applying certain offset and a limit to the number of entries to be retrieved. Makes it possible to paginate over the stored raw data.

Filter by offset and limit
GET/STH/v1/contextEntities/type/{device_type}/id/{device_id}/attributes/{attr}?hLimit={hLimit}&dateFrom={dateFrom}&dateTo={dateTo}

Example URI

GET http://localhost:8000/STH/v1/contextEntities/type/termometer/id/labtemp/attributes/temperature?hLimit=3&dateFrom=2015&dateTo=2015
URI Parameters
HideShow
device_type
string (required) Example: termometer

Type of the entity whose associated raw data wants to be retrieved.

device_id
string (required) Example: labtemp

Identifier of the entity whose associated raw data wants to be retrieved.

attr
string (required) Example: temperature

Name of the attribute whose associated raw data wants to be retrieved.

hLimit
number (optional) Example: 3

Maximum number of raw data entries to retrieve.

dateFrom
string (required) Example: 2015

01-01T00:00:00.000Z (optional, date) - The starting date from which the raw data should be retrieved. If not provided, the origin of time is used.

dateTo
string (required) Example: 2015

12-31T23:59:59.999Z (optional, date) - The final date until which the raw data should be retrieved. If not provided, the current date is used.

Request
HideShow
Headers
Content-Type: application/json
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json; charset=UTF-8
Body
{
  "contextResponses": [
    {
      "contextElement": {
        "attributes": [
          {
            "name": "temperature",
            "values": [
              {
                "recvTime": "2014-02-14T13:43:33.306Z",
                "attrValue": "21.28"
              },
              {
                "recvTime": "2014-02-14T13:43:34.636Z",
                "attrValue": "23.42"
              },
              {
                "recvTime": "2014-02-14T13:43:35.424Z",
                "attrValue": "22.12"
              }
            ]
          }
        ],
        "id": "labtemp",
        "isPattern": false,
        "type": "termometer"
      },
      "statusCode": {
        "code": "200",
        "reasonPhrase": "OK"
      }
    }
  ]
}

Filtering by number of last entries

Gets the raw data stored by the STH since certain date backwards (or the current time if no final date is provided) limiting the number of results to be retrieved.

Get raw data from STH
GET/STH/v1/contextEntities/type/{device_type}/id/{device_id}/attributes/{attr}?lastN={lastN}&dateFrom={dateFrom}&dateTo={dateTo}

Example URI

GET http://localhost:8000/STH/v1/contextEntities/type/termometer/id/labtemp/attributes/temperature?lastN=5&dateFrom=2015&dateTo=2015
URI Parameters
HideShow
device_type
string (required) Example: termometer

Type of the entity whose associated raw data wants to be retrieved.

device_id
string (required) Example: labtemp

Identifier of the entity whose associated raw data wants to be retrieved.

attr
string (required) Example: temperature

Name of the attribute whose associated raw data wants to be retrieved.

lastN
number (required) Example: 5

Number of raw data entries to retrieve since the final date backwards.

dateFrom
string (required) Example: 2015

01-01T00:00:00.000Z (optional, date) - The starting date from which the raw data should be retrieved. If not provided, the origin of time is used.

dateTo
string (required) Example: 2015

12-31T23:59:59.999Z (optional, date) - The final date until which the raw data should be retrieved. If not provided, the current date is used.

Request
HideShow
Headers
Content-Type: application/json
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json; charset=UTF-8
Body
{
  "contextResponses": [
    {
      "contextElement": {
        "attributes": [
          {
            "name": "temperature",
            "values": [
              {
                "recvTime": "2014-02-14T13:43:33.306Z",
                "attrValue": "21.28"
              },
              {
                "recvTime": "2014-02-14T13:43:34.636Z",
                "attrValue": "23.42"
              },
              {
                "recvTime": "2014-02-14T13:43:35.424Z",
                "attrValue": "22.12"
              }
            ]
          }
        ],
        "id": "labtemp",
        "isPattern": false,
        "type": "termometer"
      },
      "statusCode": {
        "code": "200",
        "reasonPhrase": "OK"
      }
    }
  ]
}

Generated by aglio on 02 Oct 2018