List of snaps that can be refreshed

Hey everyone,

I’m developing an application which runs on Ubuntu Core. The application should list all installed snaps along with versions and available updates. I use the snapd rest api for this and my approach is as follows:

List all installed snaps:

curl -sS --unix-socket /run/snapd.socket http://localhost/v2/snaps

For each of the returned snaps remember:

  • $SNAP_NAME = “name” field of the response
  • $TRACKING_CHANNEL = “tracking-channel” field of the response

and run

curl -sS --unix-socket /run/snapd.socket http://localhost/v2/find?name=$SNAP_NAME

and finally in the response check the newest version in channels[$TRACKING_CHANNEL]

Is this the right way to do this or can this be done more easily?

Thanks for the help.

You can take a look at snapd source code, specifically what snap refresh --list does.

Hi,

ok I looked it up in the source:

snap refresh --list is using:

curl -sS --unix-socket /run/snapd.socket http://localhost/v2/find?select=refresh

So, I guess I will do it similar to this.