Query a Device
Function
This API is used by an application to query the details of a specific device on the IoT platform.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
URI
GET /v5/iot/{project_id}/devices/{device_id}
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Parameter description: project ID. For details about how to obtain the project ID, see Obtaining a Project ID. |
device_id |
Yes |
String |
Parameter description: device ID, which uniquely identifies a device. The value of this parameter is specified during device registration or allocated by the platform. If the value is allocated by the platform, the value is in the format of [product_id][node_id]. Value: The value can contain a maximum of 128 characters. Only letters, digits, underscores (), and hyphens (-) are allowed. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
No |
String |
Parameter description: user token. You can obtain the token by calling the IAM API Obtaining a User Token Through Password Authentication. X-Subject-Token in the response header returned by the API is the desired user token. For details about how to obtain the token, see Token Authentication. |
Instance-Id |
No |
String |
Parameter description: instance ID. Unique identifier of each instance in the physical multi-tenant scenario. Mandatory for professional editions and recommended in other cases. Log in to the IoTDA console and choose Overview in the navigation pane to view the instance ID. For details, see Viewing Instance Details. |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
app_id |
String |
Resource space ID. Maximum: 36 |
app_name |
String |
Resource space name. |
device_id |
String |
Device ID, used to uniquely identify a device. The value of this parameter is specified during device registration or allocated by the platform. If the value is allocated by the platform, the value is in the format of [product_id]_[node_id]. |
node_id |
String |
Device identifier. This parameter is set to the IMEI, MAC address, or serial number. |
gateway_id |
String |
Gateway ID, which is the device ID of the parent device. The gateway ID is the same as the device ID if the device is a directly connected device. If the device is an indirectly connected device, the gateway ID is the device ID of the directly connected device with which it associates. |
device_name |
String |
Device name. |
node_type |
String |
Device node type.
|
description |
String |
Device description. |
fw_version |
String |
Firmware version of the device. |
sw_version |
String |
Software version of the device. |
device_sdk_version |
String |
Device SDK information. |
auth_info |
AuthInfoRes object |
Access authentication information about the device. |
product_id |
String |
Unique ID of the product associated with the device. |
product_name |
String |
Name of the product associated with the device. |
status |
String |
Device status.
|
create_time |
String |
Time when the device was registered on the platform. The value is in the format of yyyyMMdd'T'HHmmss'Z', for example, 20151212T121212Z. |
connection_status_update_time |
String |
Time of the last device connection status change. Such statuses include ONLINE, OFFLINE, and ABNORMAL. The value is in the format of yyyy-MM-dd'T'HH:mm:ss.SSS'Z', for example, 2015-12-12T12:12:122Z. |
active_time |
String |
Time when a device was activated. The value is in the format of yyyy-MM-dd'T'HH:mm:ss.SSS'Z', for example, 2015-12-12T12:12:122Z. |
tags |
Array of TagV5DTO objects |
List of device tags. |
extension_info |
Object |
Extended device information, which can be customized. If this parameter is specified for a child device during device creation, the platform will notify the gateway of the extended information using the MQTT API for notifying a gateway of new child device connection. |
Parameter |
Type |
Description |
---|---|---|
auth_type |
String |
Parameter description: authentication type. If auth_type is not specified, the secret authentication is used. Options:
|
secret |
String |
Parameter description: device secret. This parameter is mandatory when auth_type is set to SECRET. Note: Due to protocol restrictions, NB-IoT device secrets must be hexadecimal values. This parameter is not returned when you query a device list. Value: The value can contain 8 to 32 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed. Minimum: 8 Maximum: 32 |
secondary_secret |
String |
** Parameter description**: secondary device secret used when the master secret fails to pass the authentication. This parameter is valid when auth_type is set to SECRET. Unavailable for devices accessed using CoAP. Note: Due to protocol restrictions, NB-IoT device secrets must be hexadecimal values. This parameter is not returned when you query a device list. Value: The value can contain 8 to 32 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed. Minimum: 8 Maximum: 32 |
fingerprint |
String |
Parameter description: certificate fingerprint. This parameter is valid when auth_type is set to CERTIFICATES. If this parameter is not specified during device registration, the certificate fingerprint used during the first device access is used. Value: The value is a string of 40 or 64 hexadecimal characters. |
secondary_fingerprint |
String |
** Parameter description**: secondary certificate fingerprint used when the master fingerprint fails to pass the authentication. This parameter is valid when auth_type is set to CERTIFICATES. Value: The value is a string of 40 or 64 hexadecimal characters. |
secure_access |
Boolean |
Parameter description: whether the device is connected to the platform using a secure protocol. Options:
Default: true |
timeout |
Integer |
Parameter description: validity period for device access, in seconds. The default value is 0. If the device has not been connected to the IoT platform and activated within the validity period, the IoT platform deletes the registration information of the device. If this parameter is set to 0 (recommended), the platform does not delete the device registration information. Note: This parameter is only available for directly connected devices. Minimum: 0 Maximum: 2147483647 Default: 0 |
Parameter |
Type |
Description |
---|---|---|
tag_key |
String |
Parameter description: tag key, which is unique for a resource. If the specified key already exists, the value of the existing tag is overwritten. If the specified key does not exist, a new tag is added. Value: The value can contain a maximum of 64 characters. Only letters, digits, underscores (_), periods (.), and hyphens (-) are allowed. |
tag_value |
String |
Parameter description: tag value. Value: The value can contain a maximum of 128 characters. Only letters, digits, underscores (_), periods (.), and hyphens (-) are allowed. |
Example Requests
Queries details about a specified device.
GET https://{endpoint}/v5/iot/{project_id}/devices/{device_id}
Example Responses
Status code: 200
OK
{ "app_id" : "jeQDJQZltU8iKgFFoW060F5SGZka", "app_name" : "testAPP01", "device_id" : "d4922d8a-6c8e-4396-852c-164aefa6638f", "node_id" : "ABC123456789", "gateway_id" : "d4922d8a-6c8e-4396-852c-164aefa6638f", "device_name" : "dianadevice", "node_type" : "ENDPOINT", "description" : "watermeter device", "fw_version" : "1.1.0", "sw_version" : "1.1.0", "auth_info" : { "auth_type" : "SECRET", "secret" : "3b935a250c50dc2c6d481d048cefdc3c", "fingerprint" : "dc0f1016f495157344ac5f1296335cff725ef22f", "secure_access" : true, "timeout" : 0 }, "product_id" : "b640f4c203b7910fc3cbd446ed437cbd", "product_name" : "Thermometer", "status" : "ONLINE", "create_time" : "20190303T081011Z", "connection_status_update_time" : "2019-03-03T08:10:111Z", "active_time" : "2019-03-03T08:10:111Z", "tags" : [ { "tag_key" : "testTagName", "tag_value" : "testTagValue" } ], "extension_info" : { "aaa" : "xxx", "bbb" : 0 } }
Status Codes
Status Code |
Description |
---|---|
200 |
OK |
400 |
Bad Request |
401 |
Unauthorized |
403 |
Forbidden |
404 |
Not Found |
500 |
Internal Server Error |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot