Want Statistics for Your Apps Using the Galaxy Store Developer API?
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: new downloads: the number of devices on which users have downloaded the app for the first time. downloads by devices: the number of devices on which users have downloaded the app. sales: total income the app has generated. 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: new downloads: the number of devices on which users have downloaded the app for the first time. sales: total income the app has generated. item purchases: number of items purchased and number of canceled payments. average rating: daily average rating this app has received. 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 how to create an access token for the galaxy store developer api using python: an access token is sent in the authorization header of every galaxy store developer api call. learn to create an access token using the galaxy store developer api and python. app management using the galaxy store developer api and python: upload and submit an update to your app using the galaxy store developer api and python. managing in-app items using the galaxy store api and python: view, create, modify, and remove in-app items using the iap publish api and python.