Want Statistics for Your Apps Using the Galaxy Store Developer API?

Jakia Sultana

Engineer, Samsung Developer Program

You must have heard about Galaxy Store, where developers sell their apps, themes, and watch faces to Galaxy device users. The Galaxy Store Seller Portal has an amazing tool called Galaxy Store Statistics (GSS). This tool provides information about your sales, revenue, ratings, and much more, which helps you to make more effective business decisions.

If you want to collect this data programmatically, you can use the Galaxy Store Developer (GSD) API. This is a set of server-to-server APIs that allows you to manage apps, manage in-app items, and check app statistics. GSS API is one of these GSD APIs. The GSS API provides programmatic access to some of the statistics in the GSS system. You can get the data you are interested in and view it using your own UI. If your app is being sold in more than one app store, then you can view and compare the data in one page. The GSS API also helps you in data analysis.

What is the GSS API?

The GSS Metric API provides statistics for all registered apps and for a particular app.

In this blog article, I show how you can call this API and get statistical data from your apps. Since Python is the top choice among major developers, I am going to demonstrate how to implement the GSS APIs using this language. Let's get started!

Get Started

First, you need to install Python on your PC. The rest of this guide assumes you have already done this.

Prerequisites:

  • Service account ID: Create a seller account in Galaxy Store Seller Portal and get the service account ID. You can find the details here.

  • Authorization: Get the access token from the Galaxy Store authentication server using the accessToken API. Check out this blog to learn about creating the access token using Python.

After getting these required values, we are ready to call the GSS API.

GSS Metric API

The GSS Metric API provides two types of metric APIs: one for viewing the statistics of all the registered apps of a seller and the other for viewing the statistics of one particular app of a seller. Both of these APIs are discussed below.

View seller metrics

The sellerMetric API is a part of the GSS Metric API. This API provides statistics of all apps registered in Galaxy Store for a given seller ID. Currently, this API can show four types of statistics:

  1. New downloads: The number of devices on which users have downloaded the app for the first time.

  2. Downloads by devices: The number of devices on which users have downloaded the app.

  3. Sales: Total income the app has generated.

  4. Item sales: Sales an item has generated.

Each type of statistic has its own metric ID. We have to add the metric ID or IDs in our request to view the specific statistic of all the registered apps. We also have to set a period to view the data in a particular time range. Both the metric ID and time period are mandatory to call this API.

There are numerous ways to view the data of a particular metric ID. For example, we can get a daily trend value, content metadata. and filtered data based on the country or device. It's also possible to get aggregated data based on the day, week, or month.

First, let's go through an example where we get all four types of statistics of all registered apps. To compare between a previous period and the current period, two time periods have to be set. Each period is a range of time, denoted by "startDate" and "endDate". In this example, we set the current period as 8th March to 14th March and the previous period as 1st March to 7th March. We want to see the data based on all countries and devices, so we don't specify any country or device in the filter attribute. Since we want to see the filtered data, we have to set "getBreakdownsByFilter" to True. Finally, we can show the data aggregated by day.

Let's start to write the Python script. As we have seen earlier, we need the requests library. So first, let's import it in our script. We also need to import the json library because we have to send our data as a string.

# Importing the requests library 
import requests   
 
# Importing the json library 
import json 

Now, create a dictionary to hold the data which will be sent to API. Here, we need to send serialized data in the form of a string and thus json.dumps is necessary to perform the serialization. It is for this reason that we imported the json library earlier.

# Data to be sent to the API 
payload = json.dumps({ 
  "periods": [ 
    { 
      "startDate": "2022-03-08", 
      "endDate": "2022-03-14" 
    },   
    {        
      "startDate": "2022-03-01",
      "endDate": "2022-03-07" 
    } 
  ],
  "getDailyMetric": False,
  "getBreakdownsByFilter": True, 
  "noContentMetadata": True, 
  "metricIds": [  
    "total_unique_installs_filter", 
    "revenue_total",  
    "dn_by_total_dvce", 
    "revenue_item"  
  ],   
  "filters": {}, 
  "trendAggregation": "day"  
})   

Finally, define the URL and send the POST request.

# Defining the API endpoint 
seller_metric_url = 'https://devapi.samsungapps.com/gss/query/sellerMetric' 
 
try: 
    response = requests.post(seller_metric_url, headers=headers,data=payload)
    print(response.status_code)
    print(response.text) 
except Exception as e: 
    print(str(e))

The data we are interested in is contained in the response.

View content metrics

The contentMetric API is for retrieving statistics for a specific app or content. Currently, this API can show five types of statistics:

  1. New downloads: The number of devices on which users have downloaded the app for the first time.

  2. Sales: Total income the app has generated.

  3. Item purchases: Number of items purchased and number of canceled payments.

  4. Average rating: Daily average rating this app has received.

  5. Ratings volume: Total number of ratings that have been submitted.

The metric ID and time period are mandatory for this API, just like in the sellerMetric API. We can get filtered data based on the country or device and aggregated data based on the day, week, or month.

I will show you another example to demonstrate this API. In this example, we get all five types of statistics of a particular registered app. First, we set the current period as 2nd May to 2nd July and the previous period as 1st March to 1st May. We want to see the data based on all countries and devices, so we don't specify any country or device in the filter attribute. We want to see the summary data, so we have to set noBreakdown to True. Finally, we can show the data aggregated by day.

Let's start to write the Python script, which is largely the same as the sellerMetric API. We just need to change the data which is sent to the API, since the contentMetric API requires the content ID of an app. Let's copy the code from the sellerMetric example and create a dictionary to hold the data to be sent to the API.

payload = json.dumps({  
  "contentId": "<content-id-of-your-app>", 
  "periods": [ 
    {
      "startDate": "2021-05-02",
      "endDate": "2021-07-02" 
    },
    {  
      "startDate": "2021-03-01",
      "endDate": "2021-05-01" 
    } 
  ], 
  "noBreakdown": True, 
  "metricIds": [ 
    "total_unique_installs_filter",
    "revenue_total",  
    "revenue_iap_order_count", 
    "daily_rat_score",   
    "daily_rat_volumne"  
  ], 
  "filters": {}, 
  "trendAggregation": "day" 
})  

Finally, define the URL and send the POST request.

# Defining the API endpoint  
content_metric_url = 'https://devapi.samsungapps.com/gss/query/contentMetric'
 
try:
    response = requests.post(content_metric_url, headers=headers,data=payload)
    print(response.status_code)
    print(response.text)  
except Exception as e:  
    print(str(e))   

Conclusion

We have learned how to get statistics of all apps for a given seller and statistics for a specific app. You can keep a record of these statistics which can be helpful for your business in many ways. For example, based on this data, you can promote your app in a specific country, provide offers and give recommendations to new users. You can find more information about the GSS system here (you must be logged in to your Seller Portal account to view this documentation). You can also ask questions in the Samsung Developer forum.

Blog articles in this series

Preferences Submitted

You have successfully updated your cookie preferences.