更新时间:2019-11-22 13:16
设备通过物模型对接后,可以通过以下接口获取当前项目中的各类设备数据。
接口名称 | 接口描述 |
---|---|
getAppThing | 获取物的基本信息 |
getAppThingServiceData | 获取物的服务记录 |
getAppThingStatus | 获取物的连接状态 |
getAppThingTopo | 获取物的拓扑关系 |
getAppThingProp | 获取物的标签列表 |
getAppThingEventTimeline | 获取物的事件timeline数据 |
invokeAppThingService | 触发物的服务 |
getAppThingPropertyTimeline | 获取物的属性timeline数据 |
batchGetAppThingStatus | 批量获取物的状态 |
queryAppThingList | 查询应用物的列表 |
getAppThingProperties | 获取物的属性 |
setAppThingProperties | 设置物的属性 |
通过queryAppThingList接口作为接入范例,通过productKey可以获取到其下所有的设备列表、设备状态与设备类型等信息。
Path | 版本 | 是否登录 |
---|---|---|
/app/thing/list | 1.0.0 | 否 |
入参:
参数名 | 数据类型 | 是否必须 | 参数描述 |
---|---|---|---|
productKeyList | String | Y | 请在物联网平台->设备管理中获取 |
pageSize | Integer | N | 分页大小 |
pageNo | Integer | N | 当前页索引 |
categoryKeyList | String | N | 品类列表 |
tagList | String | N | 标签列表 |
出参:
参数名 | 数据类型 | 参数描述 |
---|---|---|
activeTime | String | 设备激活时间 |
productKey | String | 设备的Key |
nodeType | Integer | 节点类型 |
deviceName | String | 设备名称 |
utcCreateTime | Datetime | 创建时间(UTC格式) |
productName | String | 产品名称 |
utcActiveTime | Datetime | 设备激活时间(UTC格式) |
utcLastOnlineTime | Datetime | 设备最后在线时间(UTC格式) |
createTime | Datetime | 创建时间 |
lastOnlineTime | Datetime | 设备最后在线时间 |
status | String | 设备状态,OFFLINE:离线,ONLINE:在线 |
示例
入参示例**
{
"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"
}
本例通过java版本的sdk进行描述,更多语言SDK详情请查看API调用对接指引
<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>
public void propertiesTimeline() throws UnsupportedEncodingException{
IoTApiClientBuilderParams ioTApiClientBuilderParams =
new IoTApiClientBuilderParams();
// 填写应用的appkey信息
ioTApiClientBuilderParams.setAppKey("appKey");
ioTApiClientBuilderParams.setAppSecret("appSecrect");
SyncApiClient syncClient = new SyncApiClient(ioTApiClientBuilderParams);
IoTApiRequest request = new IoTApiRequest();
//设置api的版本
request.setApiVer("1.0.0");
// 接口参数
request.putParam("productKey","xxxxxx");
request.putParam("deviceName","xxxxxx");
request.putParam("identifier","OilQuantity");
request.putParam("pageSize",20);
//start与end是查询的时间范围,时间戳格式,精确到毫秒
request.putParam("start","1571022916629");
request.putParam("end","1571162916629");
request.putParam("ordered",false);
request.setVersion("1.0");// 请求协议版本
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"));
}
在文档使用中是否遇到以下问题
更多建议
匿名提交