# Inquire Historical Data of Device
Request Method: GET
URL: http://api.heclouds.com/devices/device_id/datapoints
device_id: need to be replaced with device ID
Parameter Name | Format | Required | Description |
---|---|---|---|
Datastream_id | string | no | datastream ID, multiple ids separated by commas, defaults to inquire all datastream |
start | string | no | start time of extracting datapoint, accurate to seconds, example: 2015-01-10T08:00:35 |
end | string | no | end time of extracting datapoint, accurate to seconds, example: 2015-01-10T08:00:35 |
duration | int | no | query time interval in seconds |
limit | int | no | limit maximum number of datapoint returned by this request, default to 100, range of values (0,6000] |
cursor | string | no | Specify that this request continues to extract data from the cursor location |
sort | enum | no | time sequencing, DESC: reverse order, ASC: ascending, default to ASC |
Parameter Name | Format | Description |
---|---|---|
errno | int | code for call error, 0 indicates call is successful |
error | string | error description, "succ" indicates call is successful |
data | json | device related information returned after successful interface call, see data description table |
Parameter Name | Format | Description |
---|---|---|
count | string | number of datapoints returned |
cursor | string | If this request fails to return all data, then will return the cursor parameter, user can carry carry the cursor parameter to request again and get the remaining data |
datastreams | array-json | json array of device datastream information, see datastreams description table |
Parameter Name | Format | Description |
---|---|---|
id | string | datastream name |
datapoints | array-json | json array of datapoint information, see datapoints description table |
Parameter Name | Format | Description |
---|---|---|
at | string | data record time |
value | string/int/json... | datapoint value |
Request article 1st to 100th data in datastream of device 8029377 that since zero o’clock on January 1, 2017
GET http://api.heclouds.com/devices/8029377/datapoints?datastream_id=ds&start=2017-01-01T00:00:00&limit=100 HTTP/1.1
{
"errno": 0,
"data": {
"cursor": "83900_8029377_1498708525203",
"count": 100,
"datastreams": [{
"datapoints": [{
"at": "2017-06-23 11:09:46.281",
"value": "112312"
}, {
"at": "2017-06-23 11:09:58.799",
"value": "112312"
}, {
"at": "2017-06-23 11:09:58.802",
"value": "1213"
}, {
"at": "2017-06-23 11:10:17.962",
"value": "1"
},
...
{
"at": "2017-06-29 11:55:20.198",
"value": "hello"
}],
"id": "ds"
}]
},
"error": "succ"
}
In this example, only the first 100 data since zero o’clock on January 1, 2017 are returned. If need to continue to get next data, should add cursor parameter when requesting, and can increase return number parameter-limit per request. As Example 2:
Get the article 101st data to the 1100th data since zero o’clock on January 1, 2017
GET http://api.heclouds.com/devices/8029377/datapoints?datastream_id=ds&start=2017-01-01T00:00:00&limit=1000&cursor=83900_8029377_1498708525203 HTTP/1.1
{
"errno": 0,
"data": {
"count": 1000,
"datastreams": [{
"datapoints": [{
"at": "2017-06-23 11:10:41.475",
"value": "awefa"
}, {
"at": "2017-06-23 11:11:12.839",
"value": "ad3"
},
...
{
"at": "2017-06-25 11:13:54.249",
"value": "RA414124124124"
}, {
"at": "2017-06-25 21:07:43.024",
"value": "13dfadfafzfadf#123affad"
}],
"id": "ds"
}]
},
"error": "succ"
}