V2.1 Get Device Statistics


Get the device statistics of an organization or product.


This API is available in EnOS 2.2.0 and above.

If you need to invoke this API after performing bulk updates to relevant devices using other APIs, it is recommended to wait for about 2 seconds to avoid obtaining unupdated data.

Request Format

GET https://{apigw-address}/connect-service/v2.1/devices?action=getStats

Request Parameters (URI)

Name Location (Path/Query) Mandatory/Optional Data Type Description
orgId Query Mandatory String The organization ID which the asset belongs to. How to get orgId>>
productKey Query Optional String The product key. If not specified, the query will return the device statistics under the organization.

Response Parameters

Name Data Type Description
data DeviceStats Struct The returned results of the device statistics. For details, see DeviceStats Struct.

DeviceStats Struct

Name Data Type Description
totalCount Integer The total number of devices.
onlineCount Integer The number of online devices.
offlineCount Integer The number of offline devices.
inactiveCount Integer The number of inactive devices.
disabledCount Integer The number of disabled devices.

Samples

Request Sample

url: https://{apigw-address}/connect-service/v2.1/devices?action=getStats&orgId=yourOrgId&productKey=yourProductKey
method: GET

Return Sample

{
    "code":0,
    "msg":"OK",
    "requestId":"21e4f294-824b-4eb5-913d-2ca92a230a71",
    "data": {
        "totalCount":100,
        "onlineCount":46,
        "offlineCount":24,
        "inactiveCount":26,
        "disabledCount":4
    }
}

SDK Samples


You can access the SDK samples for Connection Service on GitHub: