Help Center/ Intelligent EdgeFabric/ API Reference/ API/ End Device Management/ Querying Twin Properties of an End Device
Updated on 2023-11-23 GMT+08:00

Querying Twin Properties of an End Device

Function

This API is used to query twin properties of an end device.

URI

GET /v2/{project_id}/edgemgr/devices/{device_id}/twin

Table 1 Path parameters

Parameter

Mandatory

Description

project_id

Yes

Project ID. For details about how to obtain a project ID, see Obtaining a Project ID.

device_id

Yes

End device ID.

Request

Table 2 Parameters in the request header

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

Message body type (format).

The default value application/json is recommended.

X-Auth-Token

Yes

String

User token. The token can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Response

Response parameters

Table 3 Parameters in the response body

Parameter

Type

Description

access_protocol

String

Access protocol. The options are as follows:

  • userdefine: custom protocol
  • modbus: Modbus protocol
  • opc-ua: OPC UA protocol

twin

Object

Dynamic properties of an end device. A maximum of 64 key-value pairs are supported.

The key indicates the property name. For details about the format of value, see Table 21. The following is an example:

"devicestate":{ 
                      "expected":{ 
                           "value":"running", 
                           "metadata":{ 
                                "timestamp":1536822119463 
                                } 
                           }, 
                     "optional":true, 
                     "metadata":{ "type":"string" } 
                     }

property_visitors

Table 25 object

Twin property configuration, which varies depending on access_protocol.

Example response

{
    "access_protocol": "userdefine",
    "property_visitors": {},
    "twin": {
        "devicestate": {
            "expected": {
                "value": "running",
                "metadata": {
                    "timestamp": 1523514289
                }
            },
            "actual": {
                "value": "stop",
                "metadata": {
                    "timestamp": 1523514289
                }
            },
            "optional": true,
            "metadata": {
                "type": "string"
            }
        }
    }
}

Error Codes

For details, see Error Codes.