How to get the total downloads of my snap

Hello all,

last week I published my first snap on the snap store. Now I can see the downloads for my snap per day and I am wondering if there is a way to get the total downloads of my snap?

Thank you in advance!

Hi,

I haven’t tried it, but you could possibly use the Snapstore API metric endpoint? https://api.snapcraft.io/docs/metrics.html

@joachimmg I do not fully understand how to use this API. Can you give me documentation or point me in the right direction?

I’m not able to help with how to use the REST API, but the metrics you see on the website are not the amount of downloads but actively running instances of your app (i.e. your actual users)

Do you know where I could ask to get some help with the rest API?

After more research, I found this Snapcraft metrics, which seems to provide the information I wanted to know.

1 Like

I am now using this simple python script to count all new installs since the creation of the snap, which is basically what I wanted.

import os
import json



if __name__ == "__main__":
    stream = os.popen('snapcraft metrics <SNAP_NAME> --name daily_device_change --format=json --start <DATE_WHEN_THE_SNAP_RELEASED>')
    output = stream.read()
    metric = json.loads(output)
    for i in metric["series"]:
        if("name" in i and i["name"] == "new"):
            values = [int(value) for value in i["values"] if value != None]
            print(sum(values))

1 Like