Get Device Statistics


Get the device statistics of an organization or product.

Operation Permissions

Required Authorization

Required Operation Permission

Device Management

Read

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
    }
}

Java SDK Sample

package com.envisioniot.enos.connect_service;

import com.envision.apim.poseidon.config.PConfig;
import com.envision.apim.poseidon.core.Poseidon;
import com.envisioniot.enos.connect_service.v2_1.device.GetDeviceStatsRequest;
import com.envisioniot.enos.connect_service.v2_1.device.GetDeviceStatsResponse;

public class GetDeviceStats {

    public static void main(String[] args) {
        String appKey = "yourAppKey";
        String appSecret = "yourAppSecret";
        String serverUrl = "yourServerUrl";

        String orgId = "yourOrgId";
        GetDeviceStatsRequest request = new GetDeviceStatsRequest();
        request.setOrgId(orgId);
        request.setProductKey("yourProductKey");
        GetDeviceStatsResponse response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
                .url(serverUrl)
                .getResponse(request, GetDeviceStatsResponse.class);
    }
}