Back to top

Historic

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

Resource Group

Filtering by device id

Gets the raw data for a device attribute

Get raw data
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"
  }
]

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.

Get raw data
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
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 12 Apr 2018