We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
Application DistributionAppGallery Connect (HarmonyOS 5 or Later)Open Capabilities of AppGallery ConnectAppGallery Connect APIProvisioning API ReferenceQuerying the Device List

Querying the Device List

Function

This API is used to query information about devices.

Prototype

Protocol

HTTPS GET

Direction

Your server -> Huawei server

URL

https://connect-api.cloud.huawei.com/api/publish/v2/device/list

Data Format

Request: Content-Type: application/json

Response: Content-Type: application/json

Request Parameters

Header

NOTE

This API supports the Service Account, API client, and OAuth client modes. For details about their differences, please refer to Obtaining Authorization from the Server.

Service Account mode

Expand

Parameter

Mandatory

Type

Description

Authorization

Yes

String

Authorization information in Authorization: Bearer ${JWT} format. Here JWT is the authentication token obtained when you obtain authorization using the Service Account mode.

API client mode

Expand

Parameter

Mandatory

Type

Description

client_id

Yes

String

Client ID. For details about how to obtain the value, please refer to Creating an API Client.

Authorization

Yes

String

Authorization information in Authorization: Bearer ${access_token} format. In the format, access_token is obtained in Obtaining a Token.

OAuth client mode

Expand

Parameter

Mandatory

Type

Description

teamId

Yes

String(64)

ID of the team that you belong to.

oauth2Token

Yes

String

Authorization information. Pass the access token obtained via the API for obtaining an access token.

Query

Expand

Parameter

Mandatory

Type

Description

deviceName

No

String(256)

Device name.

Fuzzy search is supported.

fromRecCount

No

Integer(32)

Start page number.

Minimum value: 1

Default value: 1

maxReqCount

No

Integer(32)

Number of records returned on each page.

Value range: 1 to 100

Default value: 20

order

No

Integer(32)

Result sorting mode.

The options are as follows:

  • 1: by creation time in descending order
  • 2: by device name in ascending order

Request Example

Collapse
Word wrap
Dark theme
Copy code
  1. GET /api/publish/v2/device/list?deviceName=testDevice HTTP/1.1
  2. Host: connect-api.cloud.huawei.com
  3. client_id: 41******68
  4. Content-Type: application/json
  5. Authorization: Bearer ******

Response Parameters

Expand

Parameter

Mandatory

Type

Description

ret

Yes

ConnectRet

Result code and description.

totalCount

Yes

Integer(32)

Total number of records.

deviceList

No

List<DeviceInfo>

Device details.

Response Example

Collapse
Word wrap
Dark theme
Copy code
  1. {
  2. "ret": {
  3. "code": 0,
  4. "msg": "success"
  5. },
  6. "deviceList": [
  7. {
  8. "id": "14***************80",
  9. "deviceName": "testDevice"
  10. "udid": "111111111222****************************************333333444444",
  11. "deviceType": 1,
  12. "createTime": "2024-06-14 11:55:28.676",
  13. }
  14. ],
  15. "totalCount": 1
  16. }

Call Example

Java sample code:

Collapse
Word wrap
Dark theme
Copy code
  1. public static JSONObject getDeviceList(String domain, String clientId, String token, String deviceName) {
  2. HttpGet get = new HttpGet(domain + "/publish/v2/device/list?deviceName=" + deviceName);
  3. get.setHeader("Authorization", "Bearer " + token);
  4. get.setHeader("client_id", clientId);
  5. try {
  6. CloseableHttpClient httpClient = HttpClients.createDefault();
  7. CloseableHttpResponse httpResponse = httpClient.execute(get);
  8. int statusCode = httpResponse.getStatusLine().getStatusCode();
  9. if (statusCode == HttpStatus.SC_OK) {
  10. BufferedReader br = new BufferedReader(
  11. new InputStreamReader(httpResponse.getEntity().getContent(), Consts.UTF_8));
  12. String result = br.readLine();
  13. return JSON.parseObject(result);
  14. }
  15. } catch (Exception ignored) {
  16. }
  17. return null;
  18. }
Search in Distribute Apps
Enter a keyword.