This document describes the service APIs for devices. Client applications can use these APIs to query and control device information, including basic details, reported data, and Thing Specification Language (TSL) definitions.
Query and control device status
- Retrieve basic information about a device
- Retrieve the property timeline data of a device
- Retrieve the event timeline data of a device
- Set the properties of a device
- Retrieve the events of a device
- Retrieve the TSL template of a device by device ID
- Retrieve the TSL template of a device by ProductKey
- Retrieve the properties of a device
- Invoke a service of a device
- Retrieve the connection status of a device
- Execute a factory reset task
- Query the execution status of a factory reset task
Device extension properties
- Set device extension information
- Retrieve device extension information
- Delete device extension information
Device timers
- Create a scheduled timer scenario
- Update a scheduled timer scenario
- Delete a scheduled timer scenario
- Retrieve the details of a scheduled timer scenario
- Query a list of scheduled timer scenarios
Control devices with app widgets
Get basic information about a thing
Description
| path | Version | Description | User authentication required |
| /thing/info/get | 1.0.2 | Gets information about a thing, such as the device name, MAC address, and device activation time. | Yes. The client software development kit (SDK) must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| iotId | String | Yes | The unique identifier of the thing. |
Response parameters
| Parameter | Type | Required | Description |
| gmtModified | Long | Yes | The time when the device record was last modified. This is an internal field and can be ignored. |
| activeTime | Long | No | The time when the device was first activated. |
| gmtCreate | Long | Yes | The time when the device record was created. For IoT Platform, this is the time when the device certificate was generated during mass production. |
| productKey | String | Yes | Product key |
| statusLast | Integer | Yes | The previous device status. |
| mac | String | No | The MAC address. |
| deviceSecret | String | Yes | Device secret |
| iotId | String | Yes | The unique identifier of the device. |
| name | String | Yes | The device name. |
| sdkVersion | String | No | The SDK version number. |
| sn | String | No | The device SN. |
| thingType | String | Yes | The device type.
|
| firmwareVersion | String | No | The firmware version number. |
| rbacTenantId | String | Yes | The tenant ID. |
| status | Integer | Yes | The device status.
|
| netAddress | String | No | The IP address. |
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.2", "iotToken": "token" }, "params": { "iotId": "D95D2429xxxxE4F31A2697" } } - Successful response example
{ "code": 200, "data": { "gmtModified": 1517918765000, "activeTime": null, "gmtCreate": 1500017648000, "productKey": "kQxxxxqA", "statusLast": null, "mac": null, "netAddress": null, "deviceSecret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "iotId": "D95D242xxxxxxxx4F31A2697", "name": "Kq7rgxxxxxwJh", "nickname": null, "sdkVersion": null, "sn": null, "thingType": "DEVICE", "firmwareVersion": "1.0.0", "rbacTenantId": "ADSBCxxxx918327917", "status": 1 }, "message": "success", "localizedMsg": null }
Get the property timeline data of a thing
Description
| path | Version | Description | User authentication required |
| /living/device/property/timeline/get | 1.0.0 | Gets the property timeline data of a thing. You can retrieve up to one year of data. Note After you call /living/device/reset, this API will no longer retrieve the historical data of the device. | Yes. The client SDK must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| iotId | String | Yes | The unique identifier of the thing. |
| identifier | String | Yes | The property identifier. |
| start | Long | Yes | The start time of the timeline. |
| end | Long | Yes | The end time of the timeline. |
| limit | Int | Yes | The maximum number of entries to query. The maximum value is 200. |
| order | String | Yes |
|
Response parameters
| Parameter | Type | Required | Description |
| iotid | String | Yes | The device identifier. |
| data | String | Yes | The timeline data of the device. |
| modifytime | Long | Yes | The time when the property was updated. |
| property | String | Yes | The property identifier. |
| batchId | String | Yes | The batch ID. Properties reported in the same batch from the device have the same batch ID. |
| timestamp | Long | Yes | The timestamp when the property was collected. |
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.0", "iotToken": "token" }, "params": { "iotId": "D95D24xxxxCCE4F31A2697", "identifier": "xxxx", "start": 1517217645000, "end": 1517217645000, "limit": 10, "order": "asc" } } - Successful response example
{ "code": 200, "message": "success", "localizedMsg": null, "data": { "items": [ { "iotid": "D95D24294xxxxxxxx4F31A2697", "data": "1.23", "modifytime": 1511812747287, "property": "Lixxxxt", "batchId": "2fc766cxxxxxxxxed1f3e4b61803", "timestamp": 1511812747245 }, { "iotid": "xqxyZjSKzxxxxxxxx010851c00", "data": 1.24, "modifytime": 1511812747288, "property": "Lxxxxlt", "batchId": "2fc766cxxxx1f3e4b61803", "timestamp": 1511812747245 } ], "timestamp": 1511812747245 } }
Get the event timeline data of a thing
Description
| path | Version | Description | User authentication required |
| /living/device/event/timeline/get | 1.0.0 | Gets the event timeline data of a thing. You can retrieve up to one year of data. | Yes. The client SDK must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| iotId | String | Yes | The unique identifier of the thing. |
| identifier | String | Yes | Property Identifier |
| eventType | String | Yes | The event type. |
| start | Long | Yes | The start time of the timeline. |
| end | Long | Yes | The end time of the timeline. |
| limit | Int | Yes | The maximum number of entries to query. The maximum value is 200. |
| order | Boolean | Yes |
|
Response parameters
| Parameter | Type | Required | Description |
| eventCode | String | Yes | The event identifier. |
| iotId | String | Yes | The unique identifier of the thing. |
| eventName | String | Yes | The event name. |
| eventType | String | Yes | The event type. |
| eventBody | String | Yes | Event parameters |
| batchId | String | Yes | The batch ID. Events reported in the same batch from the device have the same batch ID. |
| timestamp | Long | Yes | The time when the data was collected. |
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.0", "iotToken": "token" }, "params": { "iotId": "D95D24xxxxE4F31A2697", "identifier": "xxxx", "eventType": "xxxx", "start": 1517217645000, "end": 1517217645000, "limit": 10, "order": "asc" } } - Successful response example
{ "code": 200, "message": "success", "localizedMsg": "", "data": { "items": [ { "eventCode": "Error", "iotId": "D95D24xxxxECCE4F31A2697", "eventName": "Fault Report", "eventType": "info", "eventBody": "{\"ErrorCode\": 0}", "batchId": "5ebc6axxxx3edde6d28c8fb3", "timestamp": 1516342985261 }, { "eventCode": "Error", "iotId": "YzqEnI5xxxxo0010840500", "eventName": "Fault Report", "eventType": "info", "eventBody": "{\"ErrorCode\": 0}", "batchId": "4a0b5a7xxxxxxxx8d5ff77456f1", "timestamp": 1516342995305 } ], "timestamp": 1516343075699 } }
Set the properties of a thing
Description
| path | Version | Description | User authentication required |
| /thing/properties/set | 1.0.2 | Set the properties of a thing | Yes. The client SDK must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| iotId | String | Yes | The unique identifier of the thing. |
| items | JSON | Yes | Set the parameter |
Response parameters
None
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.2", "iotToken": "token" }, "params": { "iotId": "D95D242xxxxE4F31A2697", "items": { "LightSwitch1": 0, "LightSwitch2": 0 } } } - Successful response example
{ "code": 200, "data": null, "message": "success", "localizedMsg": "" }
Get the events of a thing
Description
| path | Version | Description | User authentication required |
| /thing/events/get | 1.0.2 | Gets the latest reported events of a thing. If an event has not been reported, it is not returned. | Yes. The client SDK must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| iotId | String | Yes | The unique identifier of the thing. |
Response parameters
| Parameter | Type | Required | Description |
| identifier | String | Yes | The event identifier. |
| time | Long | Yes | The time when the data was collected. |
| type | String | Yes | The event type. |
| value | Object | Yes | The response parameters of the event. |
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.2", "iotToken": "token" }, "params": { "iotId": "D95D24xxxxCE4F31A2697" } } - Successful response example
{ "code": 200, "data": [ { "identifier": "Error", "time": 1517420842314, "type": "info", "value": { "Shrink5": 12, "Shrink20": { "testKey2": "val2", "testKey": "val" } } } ], "message": "success", "localizedMsg": null }
Get the TSL template of a thing by device ID
Description
| path | Version | Description | User authentication required |
| /thing/tsl/get | 1.0.2 | Gets the TSL template of a thing, which includes definitions for properties, events, and services. | Yes. The client SDK must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| iotId | String | Yes | The unique identifier of the thing. |
Response parameters
| Parameter | Type | Required | Description |
| data | JSON String | No | The TSL template JSON object of the thing. |
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.2", "iotToken": "token" }, "params": { "iotId": "D95D2xxxxCE4F31A2697" } } - Successful response example
{ "code": 200, "data": { "schema": "http://aliyun/iot/thing/desc/schema", "profile": { "productKey": "xxxxxxx", "deviceName": "xxxxxxxxxxxxxxxx" }, "link": "/sys/a1xxxxpck/YzqEnxxxx2pjjo/thing/", "services": [ { "outputData": [ ], "identifier": "ToggleLightSwitch", "inputData": [ ], "method": "thing.service.ToggleLightSwitch", "name": "Flip main light switch", "required": false, "callType": "async" } ], "properties": [ { "identifier": "LightSwitch", "dataType": { "specs": { "0": "Off", "1": "On" }, "type": "bool" }, "name": "Main light switch", "accessMode": "rw", "required": true } ], "events": [ { "outputData": [ { "identifier": "ErrorCode", "dataType": { "specs": { "0": "Normal" }, "type": "enum" }, "name": "Error code" } ], "identifier": "Error", "method": "thing.event.Error.post", "name": "Report error", "type": "info", "required": true } ] }, "message": "success", "localizedMsg": null }
Get the TSL template of a thing by ProductKey
Description
| path | Version | Description | User authentication required |
| /thing/tsl/getByProducyKey | 1.0.2 | Gets the TSL template of a thing, which includes definitions for properties, events, and services. | Yes. The client SDK must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| productKey | String | Yes | ProductKey |
| deviceName | String | No | deviceName |
Response parameters
| Parameter | Type | Required | Description |
| data | JSON String | No | The TSL template JSON object of the thing. |
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.2", "iotToken": "token" }, "params": { "ProductKey": "xxxxxxxx", "deviceName": "xxxxxxxx" } } - Successful response example
{ "code": 200, "data": { "schema": "http://aliyun/iot/thing/desc/schema", "profile": { "productKey": "xxxxxxx", "deviceName": "xxxxxxxxxxxxxxxx" }, "link": "/sys/a1xxxck/YzqEnxxxxpjjo/thing/", "services": [ { "outputData": [ ], "identifier": "ToggleLightSwitch", "inputData": [ ], "method": "thing.service.ToggleLightSwitch", "name": "Flip main light switch", "required": false, "callType": "async" } ], "properties": [ { "identifier": "LightSwitch", "dataType": { "specs": { "0": "Off", "1": "On" }, "type": "bool" }, "name": "Main light switch", "accessMode": "rw", "required": true } ], "events": [ { "outputData": [ { "identifier": "ErrorCode", "dataType": { "specs": { "0": "Normal" }, "type": "enum" }, "name": "Error code" } ], "identifier": "Error", "method": "thing.event.Error.post", "name": "Report error", "type": "info", "required": true } ] }, "message": "success", "localizedMsg": null }
Get the properties of a thing
Description
| path | Version | Description | User authentication required |
| /thing/properties/get | 1.0.2 | Gets the snapshot data of all properties of a thing. | Yes. The client SDK must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| iotId | String | Yes | The identifier of the thing. |
Response parameters
| Parameter | Sub-parameter | Type | Required | Description |
| identifier | The property ID. | |||
| value | Object | Yes | The data corresponding to the property. | |
| time | Long | Yes | The time when the property was collected. |
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.2", "iotToken": "token" }, "params": { "iotId": "D95D24xxxxCE4F31A2697" } } - Successful response example
{ "code": 200, "data": { "_sys_device_mid": { "time": 1516356290173, "value": "example.demo.module-id" }, "WorkMode": { "time": 1516347450295, "value": 0 }, "_sys_device_pid": { "time": 1516356290173, "value": "example.demo.partner-id" } }, "message": "success", "localizedMsg": null }
Invoke a service of a thing
Description
| path | Version | Description | User authentication required |
| /thing/service/invoke | 1.0.2 | Invokes a service of a thing. | Yes. The client SDK must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| iotId | String | Yes | The identifier of the thing. |
| identifier | String | Yes | The service identifier. |
| args | JSON String | Yes | The input parameters of the service. |
Response parameters
| Parameter | Type | Required | Description |
| data | String | Yes | The return value type and value depend on the device-side implementation logic. |
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.2", "iotToken": "token" }, "params": { "iotId": "D95D2xxxxCE4F31A2697", "identifier": "xxxx", "args": {} } } - Successful response example
{ "code": 200, "data": xxx, // xxx is the actual return value of the service. "message": "success", "localizedMsg": "" }
Get the connection status of a thing
Description
| path | Version | Description | User authentication required |
| /thing/status/get | 1.0.2 | Gets the connection status of a thing. | Yes. The client SDK must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| iotId | String | Yes | The unique identifier of the thing. |
Response parameters
| Parameter | Type | Required | Description |
| status | Integer | Yes | The device status.
|
| time | Long | Yes | The time when the status changed. |
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.2", "iotToken": "token" }, "params": { "iotId": "D95D2xxxxCCE4F31A2697" } } - Successful response example
{ "code": 200, "data": { "time": 1517923297000, "status": 3 }, "message": "success", "localizedMsg": null, }
Execute a factory reset task
Description
| path | Version | Description | Logon required |
| /living/device/reset | 1.0.0 | Restores the factory settings of a device. This API also notifies the device and purges the device's snapshot data from the cloud. The API call returns a task ID for the factory reset task. The task runs asynchronously. Use the task ID with the "Query the execution status of a factory reset task" API to check the status. Note This API can also delete the historical data of the device. | Yes |
Request parameters
| Parameter | Type | Required | Description |
| iotId | String | Yes | The unique identifier of the device. |
Response parameters
| Parameter | Type | Description |
| taskId | String | The ID of the factory reset task. |
Examples
- Request example
{ "id":"xxx", // The request ID "version":"1.0.0", "request":{ "language":"zh-CN", "appKey":"xxx", "iotToken":"xxx", "apiVer":"1.0.0" // The API version number }, "params":{ "iotId":"xxx" } } - Successful response example
{ "code":200, "message":"success", "localizedMsg":"", "data":"taskId" }
Query the execution status of a factory reset task
Description
| path | Version | Description | Logon required |
| /living/device/reset/task/state/get | 1.0.0 | Queries the execution status of a factory reset task. | Yes |
Request parameters
| Parameter | Type | Required | Description |
| taskId | String | Yes | The ID of the factory reset task. |
Response parameters
| Parameter | Type | Description |
| data | String | The execution status of the task. Valid values: SUCCESS, FAILED, TIMEOUT, and RUNNING. |
Examples
- Request example
{ "id":"xxx", // The request ID "version":"1.0.0", "request":{ "language":"zh-CN", "appKey":"xxx", "iotToken":"xxx", "apiVer":"1.0.0" // The API version number }, "params":{ "taskId":"xxx" } } - Successful response example
{ "code":200, "message":"success", "localizedMsg":"", "data": "SUCCESS" }
Set device extension information
A single device cannot have more than 10 tags.
Description
| path | Version | Description | User authentication required |
| /thing/extended/property/set | 1.0.2 | Set extended properties for a Thing | Yes. The client SDK must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| iotId | String | Yes | The unique identifier of the thing. |
| dataKey | String | Yes | The identifier of the extension property. The identifier must be less than 64 characters in length. |
| dataValue | String | Yes | The value of the extension property. The value must be less than 128 characters in length. |
Response parameters
None
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.2", "iotToken": "token" }, "params": { "iotId": "D95D242xxxxxxxx4F31A2697", "dataKey": "xxxx", "dataValue": "xxxx" } } - Successful response example
{ "code": 200, "message": "success", "localizedMsg": null, "data": null }
Get device extension information
Description
| path | Version | Description | User authentication required |
| /thing/extended/property/get | 1.0.2 | Gets the extension property data of a thing. | Yes. The client SDK must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| iotId | String | Yes | The unique identifier of the thing. |
| dataKey | String | Yes | The identifier of the extension property. |
Response parameters
| Parameter | Type | Required | Description |
| data | String | Yes | The value of the extension property. |
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.2", "iotToken": "token" }, "params": { "iotId": "D95D2xxxxxxxxF31A2697", "dataKey": "xxxx" } } - Successful response example
{ "code": 200, "message": "success", "localizedMsg": null, "data": "xxxx" }
Delete device extension information
Description
| path | Version | Description | User authentication required |
| /thing/extended/property/delete | 1.0.0 | Deletes the extension property data of a thing. | Yes. The client SDK must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| iotId | String | Yes | The unique identifier of the thing. |
| dataKey | String | Yes | The identifier of the extension property. |
Response parameters
None
Examples
- Request example
{ "id": "1509086454181", "version": "1.0", "request": { "apiVer": "1.0.0", "iotToken": "token" }, "params": { "iotId": "D95D24xxxx4F31A2698", "dataKey": "xxxx" } } - Successful response example
{ "code": 200, "message": "success", "localizedMsg": null, "data": null }
Query the user's widget device list
Description
| path | Version | Description | User authentication required |
| /iotx/ilop/queryComponentProduct | 1.0.0 | Queries the list of a user's widget devices. | Yes. The client SDK must enable identity authentication. |
Request parameters
None
Response parameters
| Parameter | Type | Required | Description |
| data | JSON Array | Yes | A list of widget devices. For the data structure of a single device, see the "Widget device details" table below. |
Widget device details
| Parameter | Type | Required | Description |
| productKey | string | Yes | Product Comparison |
| deviceName | string | Yes | The device name. |
| iotId | string | Yes | The device ID. |
| properties | JSON Array | Yes | A list of properties. For the detailed structure, see the table below. |
| nickName | string | Yes | Alias |
| productName | string | Yes | The product name. |
| iconUrl | string | Yes | Image URL |
| deviceStatus | int | Yes | The device status. |
Property list details
| Parameter | Type | Required | Description |
| propertyIdentifier | string | Yes | The property ID. |
| propertyName | string | Yes | The property name. |
| propertyValue | string | Yes | The property value. |
| propertyDataType | string | Yes | The data type of the property value. |
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.0", "iotToken": "token" }, "params": { } } - Successful response example
{ "code": 200, "message": "success", "localizedMsg": null, "data": [{ "deviceName":"xxx", "deviceStatus":1, "iconUrl":"http://iotx-paas-admin.oss-cn-shanghai.aliyuncs.com/publish/image/xxxxxx.png", "iotId":"xxxxxx", "productKey":"xxx", "productName":"a", "properties":[{ "propertyDataType":"bool", "propertyIdentifier":"PowerSwitch", "propertyName":"Power Switch", "propertyValue":"1"}] },{ "deviceName":"xxxx", "deviceStatus":1, "iconUrl":"http://iotx-paas-admin.oss-cn-shanghai.aliyuncs.com/publish/image/xxxxx.png", "iotId":"xxxx", "productKey":"xxx", "productName":"xxx", "properties":[{ "propertyDataType":"bool", "propertyIdentifier":"LightSwitch", "propertyName":"Main Light Switch", "propertyValue":"0" }] }] }
Update the user's widget device list
Description
| path | Version | Description | User authentication required |
| /iotx/ilop/updateComponentProduct | 1.0.0 | Updates the list of a user's widget devices. | Yes. The client SDK must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| data | Array | Yes | A list of widget devices. |
Widget device details
| Parameter | Type | Required | Description |
| productKey | string | Yes | productKey |
| iotId | string | Yes | The device ID. |
| properties | Data | No | A list of properties. |
| Parameter | Type | Required | Description |
| propertyIdentifier | string | No | The property ID. |
Response parameters
None
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.0", "iotToken": "token" }, "params": { "componentProductList": [{ "iotId":"xxxxxx", "productKey":"xxx" },{ "iotId":"xxxxxx", "productKey":"xxx" }] } } - Successful response example
{ "code": 200, "message": "success", "localizedMsg": null, "data": null }
Query the property list of a user's widget devices
Description
| path | Version | Description | User authentication required |
| /iotx/ilop/queryComponentProperty | 1.0.0 | Queries the property list of a user's widget devices. | Yes. The client SDK must enable identity authentication. |
Request parameters
| Parameter | Type | Required | Description |
| productKey | string | Yes | Product key |
| iotId | string | Yes | Device ID |
| query | struct | No | The query conditions. |
Query condition details
| Parameter | Type | Required | Description |
| dataType | string | No | The data type of the property. |
| I18Language | string | No | Multilingual |
| languageList | array | No | Multilingual List |
| allLanguage | bool | No | Indicates whether to retrieve all languages. |
| replaceOrigin | bool | No | Indicates whether to replace the default language. |
Response parameters
| Parameter | Type | Required | Description |
| propertyIdentifier | string | Yes | Property ID |
| propertyName | string | Yes | The property name. |
| propertyValue | string | Yes | The property value. |
| propertyDataType | string | Yes | The data type of the property value. |
| added_component | bool | Yes | Add to widget |
Examples
- Request example
{ "id": "1509086454180", "version": "1.0", "request": { "apiVer": "1.0.0", "iotToken": "token" }, "params": { "iotId":"xxxxxx", "productKey":"xxx", "query":{ "dataType":"BOOL" } } } - Successful response example
{ "code": 200, "message": "success", "localizedMsg": null, "data": [ {"added_component":false, "dataType":"BOOL", "i18nDTO":{ "i18nData":{"name":{"zh-CN":"Power Switch"}} }, "productKey":"xxxx", "propertyIdentifier":"PowerSwitch", "propertyName":"Power Switch"} ] }