Query a Product
Function
This API is used by an application to query details of a product model that has been created on the IoT platform, including the services, properties, and commands in the product model.
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}/products/{product_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. |
product_id |
Yes |
String |
Parameter description: product ID, which uniquely identifies a product. It is allocated by the platform after the product is created on the platform. Value: The value can contain a maximum of 36 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
app_id |
No |
String |
Parameter description: resource space ID. This parameter is optional. If you have multiple resource spaces, you can use this parameter to specify the resource space that the product to be queried belongs to. If this parameter is not specified, the product in the default resource space will be queried. If there is no product in the default resource space, the earliest created product will be queried. If you have multiple resource spaces and do not want to specify this parameter, contact Huawei technical engineers to combine your resource spaces. Value: The value can contain a maximum of 36 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. |
app_name |
String |
Resource space name. |
product_id |
String |
Product ID, which uniquely identifies a product. It is allocated by the platform after the product is created on the platform. |
name |
String |
Product name. |
device_type |
String |
Device type. |
protocol_type |
String |
Protocol used by a device. Options: MQTT, CoAP, HTTP, HTTPS, Modbus, ONVIF, OPC-UA, OPC-DA, and Other. |
data_format |
String |
Format of the data reported by the device. Options: json and binary. |
manufacturer_name |
String |
Manufacturer name. |
industry |
String |
Industry to which the device belongs. |
description |
String |
Product description. |
service_capabilities |
Array of ServiceCapability objects |
List of service capabilities of the device. |
create_time |
String |
Time when a product was created on the platform. The format is yyyyMMdd'T'HHmmss'Z', for example, 20151212T121212Z. |
Parameter |
Type |
Description |
---|---|---|
service_id |
String |
Parameter description: service ID of the device. The value must be unique in a product. Value: The value can contain a maximum of 64 characters. Only letters, digits, and special characters (_?'#().,&%@!-$) are allowed. |
service_type |
String |
Parameter description: service type of the device. Value: The value can contain a maximum of 64 characters. Only letters, digits, and special characters (_?'#().,&%@!-$) are allowed. |
properties |
Array of ServiceProperty objects |
Parameter description: list of properties supported by the device service. Value: The array length cannot exceed 500. |
commands |
Array of ServiceCommand objects |
Parameter description: list of commands supported by the device service. Value: The array length cannot exceed 500. |
events |
Array of ServiceEvent objects |
Parameter description: list of events supported by the device service. Currently, event customization is not supported. You do not need to define this field when creating or modifying a product. Value: The array length cannot exceed 500. |
description |
String |
Parameter description: device service description. Value: The value can contain a maximum of 128 characters. Only letters, digits, spaces, and special characters (_?'#().,;&%@!-:$![]~/) are allowed. |
option |
String |
Parameter description: whether the device service is mandatory. Currently, this field is not a functional field and is used only for identification. Options:
Default: Optional |
Parameter |
Type |
Description |
---|---|---|
property_name |
String |
Parameter description: device property name. The value must be unique in the device service. If device property names are used as keys in the device shadow JSON file, the names cannot contain periods (.), dollar signs ($), and the null character (hexadecimal ASCII code 00). A device shadow file that contains these special characters cannot be updated. Value: The value can contain a maximum of 64 characters. Only letters, digits, and special characters (_?'#().,&%@!-) are allowed. |
data_type |
String |
Parameter description: data type of the device property. Options: int, long, decimal, string, DateTime, jsonObject, enum, boolean, and string list. |
required |
Boolean |
Parameter description: whether the device property is mandatory. The default value is false. Default: false |
enum_list |
Array of strings |
Parameter description: list of enumerated values of the device property. |
min |
String |
Parameter description: minimum value of the device property. Value length: 1–16 characters Minimum: 1 Maximum: 16 |
max |
String |
Parameter description: maximum value of the device property. Value length: 1–16 characters Minimum: 1 Maximum: 16 |
max_length |
Integer |
Parameter description: maximum length of the device property. |
step |
Double |
Parameter description: step of the device property. |
unit |
String |
Parameter description: unit of the device property. Value length: a maximum of 16 characters Maximum: 16 |
method |
String |
Parameter description: access mode of the device property. Options: RWE, RW, RE, WE, E, W, and R.
|
description |
String |
Parameter description: device property description. Value: The value can contain a maximum of 128 characters. Only letters, digits, spaces, and special characters (_?'#().,;&%@!-:$![]~/) are allowed. |
default_value |
Object |
Parameter description: default value of the device property. If the default value is set, it will be written to the desired data of the device shadow when the product is used to create a device. When the device goes online, the default value will be delivered to the device. |
Parameter |
Type |
Description |
---|---|---|
command_name |
String |
Parameter description: device command name. The value must be unique in the device service. Value: The value can contain a maximum of 64 characters. Only letters, digits, and special characters (_?'#().,&%@!-) are allowed. |
paras |
Array of ServiceCommandPara objects |
Parameter description: list of device command parameters. |
responses |
Array of ServiceCommandResponse objects |
Parameter description: list of response parameters of the device command. |
Parameter |
Type |
Description |
---|---|---|
response_name |
String |
Parameter description: name of the device command response. Value: The value can contain a maximum of 128 characters. Only letters, digits, and special characters (_?'#().,&%@!-) are allowed. |
paras |
Array of ServiceCommandPara objects |
Parameter description: list of response parameters of the device command. |
Parameter |
Type |
Description |
---|---|---|
event_type |
String |
Parameter description: device event type. The value must be unique in the device service. Value: The value can contain a maximum of 32 characters. Only letters, digits, and special characters (_?'#().,&%@!-) are allowed. |
paras |
Array of ServiceCommandPara objects |
Parameter description: list of device event parameters. |
Parameter |
Type |
Description |
---|---|---|
para_name |
String |
Parameter description: parameter name. Value: The value can contain a maximum of 32 characters. Only letters, digits, and special characters (_?'#().,&%@!-) are allowed. |
data_type |
String |
Parameter description: data type of the parameter. Options: int, long, decimal, string, DateTime, jsonObject, enum, boolean, and string list. |
required |
Boolean |
Parameter description: whether the parameter is mandatory. The default value is false. Default: false |
enum_list |
Array of strings |
Parameter description: list of enumerated values of the parameter. |
min |
String |
Parameter description: minimum value of the parameter. Value length: 1–16 characters Minimum: 1 Maximum: 16 |
max |
String |
Parameter description: maximum value of the parameter. Value length: 1–16 characters Minimum: 1 Maximum: 16 |
max_length |
Integer |
Parameter description: maximum length of the parameter. |
step |
Double |
Parameter description: step of the parameter. |
unit |
String |
Parameter description: unit of the parameter. Value length: a maximum of 16 characters Maximum: 16 |
description |
String |
Parameter description: parameter description. Value: The value can contain a maximum of 128 characters. Only letters, digits, spaces, and special characters (_?'#().,;&%@!-:$![]~/) are allowed. |
Example Requests
Queries details about a specified product.
GET https://{endpoint}/v5/iot/{project_id}/products/{product_id}
Example Responses
Status code: 200
Successful response
{ "app_id" : "jeQDJQZltU8iKgFFoW060F5SGZka", "app_name" : "testAPP01", "product_id" : "5ba24f5ebbe8f56f5a14f605", "name" : "Thermometer", "device_type" : "Thermometer", "protocol_type" : "MQTT", "data_format" : "json", "manufacturer_name" : "ABC", "industry" : "smartCity", "description" : "this is a thermometer produced by Huawei", "service_capabilities" : [ { "service_id" : "temperature", "service_type" : "temperature", "properties" : [ { "property_name" : "temperature", "required" : true, "data_type" : "decimal", "enum_list" : null, "min" : "1", "max" : "100", "max_length" : 100, "step" : 0.1, "unit" : "centigrade", "method" : "RW", "description" : "force", "default_value" : { "color" : "red", "size" : 1 } } ], "commands" : [ { "command_name" : "reboot", "paras" : [ { "para_name" : "force", "required" : false, "data_type" : "string", "enum_list" : null, "min" : "1", "max" : "100", "max_length" : 100, "step" : 0.1, "unit" : "km/h", "description" : "force" } ], "responses" : [ { "response_name" : "ACK", "paras" : [ { "para_name" : "force", "required" : false, "data_type" : "string", "enum_list" : null, "min" : "1", "max" : "100", "max_length" : 100, "step" : 0.1, "unit" : "km/h", "description" : "force" } ] } ] } ], "events" : [ { "event_type" : "reboot", "paras" : [ { "para_name" : "force", "required" : false, "data_type" : "string", "enum_list" : null, "min" : "1", "max" : "100", "max_length" : 100, "step" : 0.1, "unit" : "km/h", "description" : "force" } ] } ], "description" : "temperature", "option" : "Mandatory" } ], "create_time" : "20190303T081011Z" }
Status Codes
Status Code |
Description |
---|---|
200 |
Successful response |
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