In this article, we will examine how the client I wrote for Publishing API client works and its features, which we can use to publish the applications we have developed, which is a nice feature of the HMS world.
What is the Publishing API?
Publishing a mobile application has its own lifecycle. There are 2 ways to publish your application in the HMS ecosystem:
- Configuring your application manually via App Gallery Console and uploading it to the site.
- Publish using code with the Publishing API
Publishin API is a service that includes many features such as transferring your application to App Gallery through an API, disclosing, updating, publishing details. This service allows you to publish your application through a client if the content of your application is fixed or predetermined, instead of dealing with it manually whenever you want to update your application.
How to Use Python Client?
Go to Users and Permissions> Api Key> Connect API, create a new client if you haven’t already. Be sure to authorize, taking into account the features you will use when determining their roles (see the requirements for each endpoint in the relevant section at the link).
When you create a new client, you should create a page like this:
For package name, you need to enter the package name you used while creating your application. If you do not know or have forgotten, you can learn from the “package” section of your application’s “AndroidManifest.xml” file:
After adding the information to the pub-env.py file, when you run it by running the getAppId.py file under “examples” to test it, you will get an output similar to the following:
This ID is your unique ID information created specifically for your application in HMS system. In almost all requests you make on the API, the API will wait for you to enter this ID as a string query. For example:
Get Application Information
You can easily pull and view the application information as a json through the Publishing API. When you run examples/getAppInfo.py, it will output a json output like this:
Update Application Information
You can easily edit your app’s information in the App Gallery through the Publishing API. You can browse the parameters you can edit from here, I updated the language parameter in examples:
I defined the “update_vals” variable as a dictionary. In other words, you can send all the parameters you want to edit at once through this variable.
Preparing the Application for Different Language in App Gallery
When publishing your application in different countries, you can explain and name it in different languages. For this, you can examine the example in AddAppLanguage.py file. You should add the abbreviation of the relevant endpoint language (see the abbreviations here), the corresponding name and description of the application’s language. When you run the application you will get an output like this:
You can see the details of the language you added via AGC:
Uploading the APK File to AGC
You need to carefully fill the variables in the uploadApk.py file under the examples directory. In fact, installing an APK on the system consists of 3 steps:
- Submit a request to the Publishing API, depending on the type of file you upload, to request a custom url to the file
- Upload your APK file to Huawei Cloud system via this URL
- Associate your uploaded APK file with your application’s project in AGC.
While these are going to be done in the background, all you have to do in the Client is to enter the full path information (make sure that it is signed) on your computer (click for signature control and steps to add it to the AGC side), enter the name of your file and whether you will load it as apk or aab, and upload You can handle the process in one step. The steps I mentioned above in the background will be executed by the script:
We understand from the success message that you have correctly installed the package. When we view whether it is installed via AGC:
Apart from these endpoints I integrate, you can also check out the other features of the Publishing API here: Publishing API
To access the github repository I have explained in detail: HMS Publishing API Python Client
See you in another post… 🙂