Landscape API: Retrieve installed packages on an instance

Good afternoon,

I am using the following query to obtain the installed packages on an instance: curl -H “Authorization: Bearer xxxxxxxxx” https://landscape.xxx.com/api/v2/computers/25/packages | jq ‘.results. | select(.status == “installed”)’

This query only returns the first 3 installed packages on that instance; on this instance there are 559 installed packages.

{“name”: “adduser”,“summary”: “add and remove users and groups”,“status”: “installed”,“current_version”: “3.137ubuntu1”,“available_version”: null}{“name”: “apport-symptoms”,“summary”: “symptom scripts for apport”,“status”: “installed”,“current_version”: “0.25”,“available_version”: null}{“name”: “appstream”,“summary”: “Software component metadata management”,“status”: “installed”,“current_version”: “1.0.2-1build6”,“available_version”: null

I attach a screenshot of what the GUI shows; here it can be corroborated that it only pulls the first 3 packages.

If I don’t apply the following filter: jq ‘.results| select(.status == “installed”)’, all packages (available, security, and installed) are shown, totaling 95,767 packages.

Thanks in advance.

Regars

Welcome to Ubuntu Discourse :slight_smile:

Topic moved to Project Discussion > Landscape

I hope my translation of your title is correct, feel free to change it.

Hello rubi1200,

I didn’t see that was written in spanish, thanks for change the title, your translation was perfect.

1 Like

We use the legacy API so the options and syntax are a bit different, but I would start by adding the installed=true as a parameter before doing the jq filtering and see what comes up.

Additionally, I see you dont have the -X GET so there might be a limit you are hitting without having that defined.

Hello ib-mmsys,

Thanks for your help, the problem was the filter before jq, with this line I get the name of the package and the version:

curl -X GET -H “Authorization: Bearer xxxxxx” https://xxxxx/api/v2/computers/7/packages?installed=true | jq ‘.results| {name, current_version}’

It is resolved!

3 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.