請求方式:GET
URL: http://api.onenet.hk.chinamobile.com/devices/device_id/datapoints
device_id:需要替換為設備lD
參數名稱 | 格式 | 是否必須 | 說明 |
---|---|---|---|
datastream_id | string | 否 | 數據流ID,多個id之間用逗號分開,缺省時為查詢所有數據流 |
start | string | 否 | 提取數據點的開始時間,精確到秒,示例:2015-01-10T08:00:35 |
end | string | 否 | 提取數據點的結束時間,精確到秒,示例:2015-01-10T08:00:35 |
duration | int | 否 | 查詢時間區間,單位為秒 |
limit | int | 否 | 限定本次請求最多返回的數據點數,默認100,範圍為(0,6000] |
cursor | string | 否 | 指定本次請求繼續從cursor位置開始提取數據 |
sort | enum | 否 | 時間排序方式,DESC:倒序,ASC:昇冪,默認為ASC |
參數名稱 | 格式 | 說明 |
---|---|---|
errno | int | 調用錯誤碼,為0表示調用成功 |
error | string | 錯誤描述,為“succ”表示調用成功 |
data | json | 介面調用成功之後返回的設備相關信息,見data描述表 |
data描述表
參數名稱 | 格式 | 說明 |
---|---|---|
count | string | 本次返回的數據點數量 |
cursor | string | 本次請求若未能返回所有數據,則會返回cursor參數,用戶可以攜帶cursor參數進行再次請求,獲取剩下的數據 |
datastreams | array-json | 設備數據流信息的json陣列,見datastreams描述表 |
datastreams描述表
參數名稱 | 格式 | 說明 |
---|---|---|
id | string | 數據流名稱 |
datapoints | array-json | 數據點信息的json陣列,見datapoints描述表 |
datapoints描述表
參數名稱 | 格式 | 說明 |
---|---|---|
at | string | 數據記錄時間 |
value | string/int/json... | 數據點的值 |
請求設備8029377從2017年1月1日零點以來,數據流ds的第1至第100條數據
GET http://api.onenet.hk.chinamobile.com/devices/8029377/datapoints?datastream_id=ds&start=2017-01-
{
"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"
}
本示例中,只返回了2017年1月1日零點以來的前100條數據,若需要繼續獲取接下來的數據,需要在請求時
獲取2017年1月1日零點以來的第101條數據,到第1100條數據
GET http://api.onenet.hk.chinamobile.com/devices/8029377/datapoints?datastream_id=ds&start=2017-01-
{
"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"
}