Help Center/ IoT/ API Reference/ Northbound API Reference/ Data Collection/ Querying Service Capabilities of a Device
Updated on 2022-02-24 GMT+08:00

Querying Service Capabilities of a Device

Typical Scenario

If an NA needs to know which service attributes can be reported by a device and which commands can be delivered to the device, the NA can call this API to query the device service capabilities defined in the profile file of the device on the IoT platform.

API Function

This API is used by an NA to query device service capabilities, such as service attributes and device commands.

API Prototype

Method

GET

URL

https://server:port/iocm/app/data/v1.1.0/deviceCapabilities?appId={appId}&gatewayId={gatewayId}&deviceId={deviceId}

Transport Protocol

HTTPS

Request Parameters

Parameter

Mandatory or Optional

Type

Location

Description

app_key

Mandatory

String

header

Identifies an application that can be accessed on the IoT platform. The value of this parameter is allocated by the IoT platform when the application is created on the platform.

Authorization

Mandatory

String

header

Indicates the authentication information for accessing the IoT platform. The value is Bearer {accessToken}, in which {accessToken} indicates the access token returned by the Authentication API.

gatewayId

Optional

String

query

Identifies a gateway. 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 (that is, the gateway) with which it associates.

appId

Optional

String

query

Identifies an application that can be accessed on the IoT platform. The value of this parameter is allocated by the IoT platform when the application is created on the platform. Set this parameter to the value of appId of the authorized application.

deviceId

Optional

String

query

Uniquely identifies a device. The value of this parameter is allocated by the IoT platform during device registration.

Response Parameters

Parameter

Type

Description

deviceCapabilities

List<DeviceCapabilityDTO>

Indicates the query result list.

DeviceCapabilityDTO structure

Parameter

Type

Description

deviceId

String(256)

Uniquely identifies a device. The value of this parameter is allocated by the IoT platform during device registration.

serviceCapabilities

List<ServiceCapabilityDTO>

Indicates the list of service capabilities of a device.

ServiceCapabilityDTO structure

Parameter

Type

Description

serviceId

String(256)

Identifies a service.

serviceType

String(256)

Indicates the service type.

option

String(256)

Indicates a service option.

description

String(10240)

Indicates the service description.

commands

List<ServiceCommand>

Indicates the list of supported commands.

properties

List<ServiceProperty>

Indicates the list of supported properties.

ServiceCommand structure

Parameter

Type

Description

commandName

String(256)

Indicates the command name.

paras

List<ServiceCommandPara>

Indicates the attribute list.

responses

List<ServiceCommandResponse>

Specifies the list of responses.

ServiceCommandPara structure

Parameter

Type

Description

paraName

String(256)

Indicates the parameter name.

dataType

String(256)

Indicates the data type.

required

Boolean

Indicates whether the parameter is mandatory.

min

String

Indicates the minimum value of the attribute.

max

String

Indicates the maximum value of the attribute.

step

Double

Indicates the step.

maxLength

Integer

Indicates the maximum length.

unit

String

Indicates the unit (symbol).

enumList

List<String>

Indicates the enumeration type list.

ServiceCommandResponse structure

Parameter

Type

Description

responseName

String(256)

Indicates the response name.

paras

List<ServiceCommandPara>

Indicates the attribute list.

ServiceProperty structure

Parameter

Type

Description

propertyName

String(256)

Indicates the attribute name.

dataType

String(256)

Indicates the data type.

required

Boolean

Indicates whether the parameter is mandatory.

min

String

Indicates the minimum value of the attribute.

max

String

Indicates the maximum value of the attribute.

step

Double

Indicates the step.

maxLength

Integer

Indicates the maximum length.

method

String(256)

Indicates the access method. The values are as follows:

  • R: Readable
  • W: Writable
  • E: Observable

unit

String

Indicates the unit (symbol).

enumList

List<String>

Indicates the enumeration type list.

Request Example

Method: GET
Request:
https://server:port/iocm/app/data/v1.1.0/deviceCapabilities?appId={appId}&gatewayId={gatewayId}&deviceId={deviceId}
Header:
app_key: ******
Authorization: Bearer *****
Content-Type: application/json

Response Example

Response:
Status Code: 200 OK
Content-Type: application/json
Body:
{
    "deviceCapabilities":[
        {
            "deviceId":"****",
            "serviceCapabilities":[
                {
                    "serviceId":"****",
                    "serviceType":"****",
                    "option":"****",
                    "description":"****",
                    "commands":[
                        {
                            "commandName":"*****",
                            "paras":[
                                {
                                    "paraName":"*****",
                                    "dataType":"*****",
                                    "required":"Ture",
                                    "min":"*****",
                                    "max":"*****",
                                    "step":"*****",
                                    "maxLength":1111111,
                                    "unit":"*****",
                                    "enumList":[
                                        {

                                        }
                                    ]
                                }
                            ],
                            "responses":[
                                {
                                    "responseName":"***",
                                    "paras":[
                                        {
                                            "paraName":"*****",
                                            "dataType":"*****",
                                            "required":"Ture",
                                            "min":"*****",
                                            "max":"*****",
                                            "step":"*****",
                                            "maxLength":1111111,
                                            "unit":"*****",
                                            "enumList":[
                                                {

                                                }
                                            ]
                                        }
                                    ]
                                }
                            ],
                            "properties":[
                                {
                                    "propertyName":"*****",
                                    "dataType":"*****",
                                    "required":"Ture",
                                    "min":"*****",
                                    "max":"*****",
                                    "step":"*****",
                                    "maxLength":1111111,
                                    "method":"*****",
                                    "unit":"*****",
                                    "enumList":[
                                        {

                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

Error Codes

HTTP Status Code

Error Code

Error Description

Remarks

400

100022

The input is invalid.

An input parameter is invalid.

Recommended handling: Check whether parameters carried in the API call request are valid.

403

100203

The application is not existed.

The application does not exist.

Recommended handling:

  • Check whether appId carried in the HTTP request header is correct.
  • Check whether appId in the request path (URL) is correct.

403

100217

The application hasn't been authorized.

The application has not been authorized.

Recommended handling: In scenarios where applications are not authorized, ensure that request parameter appId is null.

403

1010009

app throttle exceed.

The NA calls the API at a frequency that exceeds the flow control threshold (100 calls per minute by default).

Recommended handling: Contact IoT platform maintenance personnel to adjust the flow control threshold or control the API call frequency.

403

1010005

App_key or access_token is invalid.

The access token is invalid.

Recommended handling: Check whether accessToken carried in the API request is correct.

500

100203

The application is not existed.

The application does not exist.

Recommended handling:

  • Check whether appId carried in the HTTP request header is correct.
  • Check whether appId in the request path (URL) is correct.

500

50252

Internal server error.

An internal server error occurs.

Recommended handling: An internal error occurs on the IoT platform. Contact IoT platform maintenance personnel.