設(shè)備數(shù)據(jù)對(duì)接指引
1、接口說明
設(shè)備通過物模型對(duì)接后,可以通過以下接口獲取當(dāng)前項(xiàng)目中的各類設(shè)備數(shù)據(jù)。
接口名稱 | 接口描述 |
獲取物的基本信息 | |
獲取物的服務(wù)記錄 | |
獲取物的連接狀態(tài) | |
獲取物的拓?fù)潢P(guān)系 | |
獲取物的標(biāo)簽列表 | |
獲取物的事件timeline數(shù)據(jù) | |
觸發(fā)物的服務(wù) | |
獲取物的屬性timeline數(shù)據(jù) | |
批量獲取物的狀態(tài) | |
查詢應(yīng)用物的列表 | |
獲取物的屬性 | |
設(shè)置物的屬性 |
2、接入指南
通過queryAppThingList接口作為接入范例,通過productKey可以獲取到其下所有的設(shè)備列表、設(shè)備狀態(tài)與設(shè)備類型等信息。
Path | 版本 | 是否登錄 |
/app/thing/list | 1.0.0 | 否 |
入?yún)ⅲ?/b>
參數(shù)名 | 數(shù)據(jù)類型 | 是否必須 | 參數(shù)描述 |
productKeyList | String | Y | 請(qǐng)?jiān)谖锫?lián)網(wǎng)平臺(tái)->設(shè)備管理中獲取 |
pageSize | Integer | N | 分頁大小 |
pageNo | Integer | N | 當(dāng)前頁索引 |
categoryKeyList | String | N | 品類列表 |
tagList | String | N | 標(biāo)簽列表 |
出參:
參數(shù)名 | 數(shù)據(jù)類型 | 參數(shù)描述 |
activeTime | String | 設(shè)備激活時(shí)間 |
productKey | String | 設(shè)備的Key |
nodeType | Integer | 節(jié)點(diǎn)類型 |
deviceName | String | 設(shè)備名稱 |
utcCreateTime | Datetime | 創(chuàng)建時(shí)間(UTC格式) |
productName | String | 產(chǎn)品名稱 |
utcActiveTime | Datetime | 設(shè)備激活時(shí)間(UTC格式) |
utcLastOnlineTime | Datetime | 設(shè)備最后在線時(shí)間(UTC格式) |
createTime | Datetime | 創(chuàng)建時(shí)間 |
lastOnlineTime | Datetime | 設(shè)備最后在線時(shí)間 |
status | String | 設(shè)備狀態(tài),OFFLINE:離線,ONLINE:在線 |
示例入?yún)⑹纠?*
{
"request": {
"apiVer": "1.0.0"
},
"id": "bfd7388e-b6ec-4abd-8832-e6a4ea5b2cbd",
"params": {
"productKeyList": ["xxxx"],
"pageSize": 20,
"pageNo": 1,
"categoryKeyList": [],
"tagList": []
},
"version": "1.0"
}
出參示例
{
"code": 200,
"data": {
"total": 1,
"data": [{
"activeTime": "2019-10-15 13:11:49",
"productKey": "xxxxxx",
"nodeType": 0,
"deviceName": "ColdRiver01",
"utcCreateTime": "2019-10-15T03:45:36.000Z",
"productName": "xxxxx",
"utcActiveTime": "2019-10-15T05:11:49.658Z",
"utcLastOnlineTime": "2019-10-16T03:27:46.604Z",
"createTime": "2019-10-15 11:45:36",
"lastOnlineTime": "2019-10-16 11:27:46",
"status": "OFFLINE"
}],
"pageNo": 1,
"pageSize": 20
},
"id": "18b32d34-0808-4ebd-b61b-79572a484535"
}
3、API調(diào)用方式
SDK依賴
本例通過Java版本的SDK進(jìn)行描述,更多語言SDK詳情請(qǐng)查看API調(diào)用對(duì)接指引
<dependency>
<groupId>com.aliyun.api.gateway</groupId>
<artifactId>sdk-core-java</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.aliyun.iotx</groupId>
<artifactId>iotx-api-gateway-client</artifactId>
<version>1.0.3</version>
</dependency>
3.2 示例代碼
public void propertiesTimeline() throws UnsupportedEncodingException{
IoTApiClientBuilderParams ioTApiClientBuilderParams =
new IoTApiClientBuilderParams();
// 填寫應(yīng)用的appkey信息
ioTApiClientBuilderParams.setAppKey("appKey");
ioTApiClientBuilderParams.setAppSecret("appSecrect");
SyncApiClient syncClient = new SyncApiClient(ioTApiClientBuilderParams);
IoTApiRequest request = new IoTApiRequest();
//設(shè)置api的版本
request.setApiVer("1.0.0");
// 接口參數(shù)
request.putParam("productKey","xxxxxx");
request.putParam("deviceName","xxxxxx");
request.putParam("identifier","OilQuantity");
request.putParam("pageSize",20);
//start與end是查詢的時(shí)間范圍,時(shí)間戳格式,精確到毫秒
request.putParam("start","1571022916629");
request.putParam("end","1571162916629");
request.putParam("ordered",false);
request.setVersion("1.0");// 請(qǐng)求協(xié)議版本
ApiResponse response = syncClient.postBody("api.link.aliyun.com",
"/app/thing/property/timeline/get", request, true);
System.out.println("response code = " + response.getCode()
+ " response = " + new String(response.getBody(), "UTF-8"));
}