HUAWEI AppGallery Connect API-REPORTS API

Hayri Aral
Huawei Developers
Published in
5 min readDec 1, 2020

Hello all, in this article, I am going to try to explain one of the feature of AppGallery Connect API which is Reports API.

What is Reports API and what it used for?

You can use Reports API in order to query most reports in AppGallery, 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.

How Reports API works?

You need to determine the date range and add a filter to query reports through the API. Reports API will provide a query result as CSV or Excel files.

The process of developing an app based on the Reports API is as follows:

  1. View report data
  2. Obtain the report download URL
  3. Download the report

Viewing Report Data

Before obtaining a report of an app, you must ensure that the corresponding report data of the app exists in AppGallery Connect and the app must have been released and promoted. To query existing report data in AppGallery Connect, perform the following steps:

  • Find your app in the list and click the app name.
  • At the top left, select a tab of analysis type and view report data on the page such as Distribution Analysis, Operations Analysis and Quality Analysis.

Obtaining the Report Download URL

You need to call the Reports API to obtain the download URL of the report CSV or Excel file.

Currently, there are 4 Report Download URLs are Download and Installation, In-app Payment, Paid Download and Installation Failure Data functioned by Reports API.

Download and Installation Report

To obtain the URL of the download and installation report CSV file.

In-app Payment Report

To obtain the URL of the in-app payment report CSV or Excel file.

Paid Download Report

To obtain the URL of the paid download report CSV file.

Installation Failure Data Report

To obtain the URL of the installation failure data report CSV file.

Before calling the Reports API, you must ensure that an API client has been created and an access token has been obtained. For details, please refer to official AppGallery Connect API guide.

You can also check Getting Started for HUAWEI AppGallery Connect API in order to learn how to obtain access token for Connect API.

I will move on with API Client Mode and use Download and Installation Report API as an example to describe Reports API-based app development. The processes of calling other APIs of the Reports API are similar. However, I will provide a sample code which included all type of reports.

Request method:

GET

Base URL:

https://connect-api.cloud.huawei.com/api/report/distribution-operation-quality/v1/

Body URL for Download and Installation Report:

appDownloadExport/

Input Parameters:

client_id -header- (String)

This parameter is created in API Client. Click here and follow Creating an API Client subtitle.

Authorization -header- (String)

Authorization information in Authorization. Bearer ${access_token} format.

appId -path- (String)

You can see it in AppGallery Connect Console or query with client. For details about how to obtain the app ID, please refer to Querying App ID.

language -query- (String)

The report title can be displayed in different languages. Presently, only simplified Chinese (zh-CN), English (en-US), and Russian (ru-RU) are supported.

startTime -query- (String)

Query start time in UTC time. The format is YYYYMMDD.

endTime -query- (String)

Query end time in UTC time. The format is YYYYMMDD.

Note: The interval between startTime and endTime cannot exceed 180 days.

filterCondition -query- (List<String>)

This parameter for filter and is optional. The options are as follows:

  • countryId: by country/region.
  • businessType: by business type.
  • appVersion: by app version.

If this parameter is not passed, no filter is used by default.

Filters countryId, businessType, and appVersion can be used at the same time. URL example: &filterCondition=countryId&filterCondition=businessType&filterCondition=appVersion

filterConditionValue -query- (List<String>)

This parameter for value of a filter and is optional.

If the filter is countryId, the value of this parameter is a string array of country/region codes, for example, CN, AL, AD, AT. For details about the country/region code list, please refer to Country/Region Codes. If the value is all, global data is queried. If others is passed, only data about US,CU,IR,SD,SY (United States, Cuba, Iran, Sudan, and Syria) is queried and the obtained data is displayed as a whole, for example, CN,AL,others. The values all and others are case insensitive.

If the filter is businessType, the options of this parameter are as follows:

The value is case sensitive.

  • ALL: all businesses
  • AppGallery: HUAWEI AppGallery
  • AppTouch: HUAWEI AppTouch

If the filter is appVersion, the parameter indicates the app version. Use commas (,) to separate multiple versions, for example, 1.0.0,2.0.0. The value all indicates that all app versions are queried and is case-insensitive.

If multiple filters are passed, the same number of filterConditionValue parameters arranged in the same order as the corresponding filters are required.

URL example: &filterConditionValue=CN&filterConditionValue=AppGallery

groupBy -query- (String)

This parameter for statistics dimension and is optional. The options are as follows:

  • date: by date
  • countryId: by country/region.
  • businessType: by business type.
  • appVersion: by app version.

The default value is date.

exportType -query- (String)

This parameter for format of an exported file. The options are as follows:

  • CSV
  • EXCEL

The default value is CSV.

Output Parameters:

fileURL (String)

Path for storing a CSV or Excel file. The report language is specified by language. The first parameter is the data statistics group type specified by groupBy.

packageName (String)

Package name of the app.

ret (String)

JSON character string containing the result code and description in {“code”:retcode, “msg”: “description”} format, in which retcode indicates the result code and description indicates the result code description.

Sample Code:

Please, change your clientId, clientSecret, appId variables as yours before run the app.

Downloading the Report

Subsequent to getting the report download URL, you can straightforwardly download the report CSV or Excel record from the URL. The document contains detailed report data.

That’s all! I hope it will help you. See you in next story.

--

--