How to get a list of all currently installed apps and their respective versions?

Hello :smiley:

I am pretty new to nextcloud developement.

I need to create an API route that sends the list of all currently installed app and their respective versions per every hour through a cron job. Is there a function in nextcloud that gets a list of the currently installed apps ? how does nextcloud actually list all the apps in the apps tab ?

Thank you for your help :slight_smile:

check out the dev manual - I don’t see any API but didn’t spent much time… what definitely works is occ app:list command but might be not what you are looking for…

P.S. listing app version every hour sounds little like overkill in my eyes but might have your reasons…

Sorry i do not know an API.
But you find e.g. versions of the apps in App metadata
Question: How to use App metadata e.g. with API?

How about using the IAppManager? Documentation is to be found in the API reference.

You can use getInstalledApps() to get a list, filter eventually by isEnabledForUser, and iterate over the list with getAppInfo() to obtain the information from the XML manifest metadata. There is the version stored.

I suspect in my answer that you are talking about creating an app for Nextcloud, that is you create an extension. If you are talking of a pure web app outside, I fear, this is not possible.

Please be aware that the exact versions of all apps might open a small security hole as security issues can be checked by an attacker beforehand. Also blacklisting etc can be detected. So at least be sure to protect the API endpoint with a user login requirement, better even an admin login requirement (default without @NoAdminRequired and @PublicPage).

1 Like