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 attributeGET/device/{device_id}/history?lastN={lastN}&attr={attr}
Example URI
- device_id
string
(required) Example: labtempIdentifier of the entity whose associated raw data wants to be retrieved.
- attr
string
(required) Example: temperatureName of the attribute whose associated raw data wants to be retrieved.
- lastN
number
(optional) Default: 1 Example: 3Last number of values for this attribute (attr)
Headers
Content-Type: application/json
Authorization: Bearer JWT
200
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 deviceGET/device/{device_id}/history
Example URI
- device_id
string
(required) Example: labtempIdentifier of the entity whose associated raw data wants to be retrieved.
- attr
string
(optional) Example: noneName of the attribute whose associated raw data wants to be retrieved. If not provided, will consider all attributes.
- lastN
number
(optional) Example: noneMaximum number of raw data entries to retrieve. If not provided, will return all data entries of the attributes.
- dateFrom
date
(optional) Example: noneThe starting date from which the raw data should be retrieved. If not provided, the origin of time is used.
- dateTo
date
(optional) Example: noneThe final date until which the raw data should be retrieved. If not provided, the current date is used.
Headers
Content-Type: application/json
Authorization: Bearer JWT
200
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 limitGET/STH/v1/contextEntities/type/{device_type}/id/{device_id}/attributes/{attr}?hLimit={hLimit}&dateFrom={dateFrom}&dateTo={dateTo}
Example URI
- device_type
string
(required) Example: termometerType of the entity whose associated raw data wants to be retrieved.
- device_id
string
(required) Example: labtempIdentifier of the entity whose associated raw data wants to be retrieved.
- attr
string
(required) Example: temperatureName of the attribute whose associated raw data wants to be retrieved.
- hLimit
number
(optional) Example: 3Maximum number of raw data entries to retrieve.
- dateFrom
string
(required) Example: 201501-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: 201512-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.
Headers
Content-Type: application/json
Authorization: Bearer JWT
200
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 STHGET/STH/v1/contextEntities/type/{device_type}/id/{device_id}/attributes/{attr}?lastN={lastN}&dateFrom={dateFrom}&dateTo={dateTo}
Example URI
- device_type
string
(required) Example: termometerType of the entity whose associated raw data wants to be retrieved.
- device_id
string
(required) Example: labtempIdentifier of the entity whose associated raw data wants to be retrieved.
- attr
string
(required) Example: temperatureName of the attribute whose associated raw data wants to be retrieved.
- lastN
number
(required) Example: 5Number of raw data entries to retrieve since the final date backwards.
- dateFrom
string
(required) Example: 201501-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: 201512-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.
Headers
Content-Type: application/json
Authorization: Bearer JWT
200
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"
}
}
]
}