Getting Started for HUAWEI AppGallery Connect API

Hayri Aral
Huawei Developers
Published in
4 min readNov 25, 2020

Hello all, in this article, I am going to attempt to clarify HUAWEI AppGallery Connect API.

What Connect API used for?

Connect API provides RESTful APIs that can be used to customize services provided by AppGallery Connect or implement process automation, thereby improving your work efficiency.

What features provided by Connect API?

Presently, there are 5 APIs which are Publishing API, Report API, Project Management API, Comments API, PMS API provided by Connect API.

Publishing API:

To manage and release apps in AppGallery Connect in RESTful mode

Reports API:

To query most analysis data in AppGallery Connect, including report data such as download and installation, reservation, user group award granting, new and retained user, in-app payment, paid download, coupon activity, and installation failure data

Project Management API:

To obtain your users’ project and configuration information from AppGallery Connect.

Comments API:

To obtain comment data from AppGallery Connect and analyze the data using your own or a third-party comment analysis system for refined operations or reply to comments.

PMS API:

To manage the prices and languages of in-app products, and implement localized pricing for all supported locations.

In order to utilize the AppGallery Connect API, you need to obtain authorization from the AppGallery Connect server in advance using either of the following modes:

API Client Mode:

Access APIs as an app according to the permissions assigned to your API client role. Use this mode when your user needs to connect their own IT system to AppGallery Connect.

OAuth Client Mode:

The OAuth client enables your app to provide various management services for users, who can be Huawei developers. Your users can sign in to your app using HUAWEI IDs and access APIs according to the permissions assigned to the role of their account in their team. Use this mode when you are developing a third-party IDE or development tool that needs to be connected to AppGallery Connect.

I will move on with API Client Mode for this article.

You need to manage your API client in AppGallery Connect. The process is as follows:

  1. Creating an API client
  2. Obtaining the token for accessing the API
  3. Accessing the API

Note: An API client can be managed only by team account holder.

Creating an API client

An API client is an identity credential used by AppGallery Connect to manage user access to the AppGallery Connect API. You can create different API clients for various roles. Users with different roles can access the AppGallery Connect API with the corresponding permissions. Before accessing an API, you must create an API client with the permission for accessing the API. The procedure is as follows:

  • On the left hand side select API Key > Connect API and click Create.
  • Set Name to a customized client name, Project to the related project, and Roles to the corresponding role, and click Confirm.

Note: Set Project as N/A to define the API client as a team-level one.

  • After the client is successfully created, you will be able to see the values of Client ID and Key in the client information list.

Obtaining Token for Accessing the API

After an API client is created, you need to obtain the token for accessing the API based on the client ID and key. So, the API should be authenticated in AppGallery Connect. In order to obtain an access token, you have to add the code for calling the Obtaining a Token API to your app program.

Base URL: https://connect-api.cloud.huawei.com/api/oauth2/v1/token

Input Parameters:

  • (String) grant_type: This parameter has a fixed value of client_credentials.
  • (String) client_id: This parameter is String and created in API Client.
  • (String) client_secret: This parameter is String and created in API Client.

Headers:

  • Content-Type: application/json

Output Parameters:

The return value is a character string in JSON format.

  • (String) access_token: Authentication token, which is used to call the AppGallery Connect API.
  • (Long) expires_in: Timestamp of the access_token expiration time.

Note: You need to call this API again to obtain a new access token when the current one expires.

Sample code:

You can also check the GitHub repo here.

Accessing the API

After obtaining an access token, you can use the access token to call the AppGallery Connect API to complete function development.

In next article, I am going to cover Connect API features with development examples.

--

--