How to get all computers information through API calls

tonystonks
New Contributor II

Hi,

 

I am trying to get information of User,  Computer Name, Operating System, Last Inventory Update and Last Check-in through APIs 

Right now, the API I'm dealing with are these 2 below:

https://xxx.jamfcloud.com/api/v1/computers-inventory

https://xxx.jamfcloud.com/uapi/preview/computers 

The problem is they are NOT returning all the computers' details only partially. I even tried with https://xxxx/uapi/preview/computers?page=1&page-size=10000000 or https://xxx/api/v1/computers-inventory?section=GENERAL&page=0&page-size=10000&sort=id%3Aasc.

Do you have any idea what did I miss ? or suggestions to another API calls ?

 

Thank you so much,

2 ACCEPTED SOLUTIONS

stevewood
Honored Contributor II
Honored Contributor II

Ah, yes, that is pretty clear when you read the subject closer... 😎

Short of using a script with a loop to cycle through each computer (which could be a lot depending on # of endpoints), the easiest way to do this is probably with an Advanced Search. Setup the search to display exactly what you want and then call the search via API. Or set it up to be a report that is emailed out.

{{url}}/JSSResource/advancedcomputersearches/id/<id>

View solution in original post

mm2270
Legendary Contributor III

This can be done if you create and save a Computer Advanced search and pull that in the API rather than other resources. The trick is to create a saved advanced search with either no criteria, or criteria that filters out the Macs you are interested in, and more importantly, add the columns of data you're interested in, such as User,  Computer Name, Operating System, Last Inventory Update and Last Check-in like you mention above.

Then in the API you can call that advanced search using the advancedcomputersearches API resource
 https://your.jamf.server/JSSResource/advancedcomputersearches/id/<id>

You'll need to parse the output in your script, but passing the result through xmllint like | xmllint --format - should make the XML structured at least.

Edit: Whoops! I didn't see @stevewood 's post above that basically suggested the same thing. So in short, I agree with him 😉 That's the best option to use when talking about the API.

View solution in original post

7 REPLIES 7

stevewood
Honored Contributor II
Honored Contributor II

You'll need to use the Classic API to get all of the info about a device.

https://developer.jamf.com/jamf-pro/reference/classic-api

The specific endpoints:

https://xxx.jamfcloud.com/JSSResource/computers/id/<id>

https://xxx.jamfcloud.com/JSSResource/computers/serialnumber/<serialnumber>

Either of those will work.

Thanks Steve, I understood those APIs but they are limited to just a single computer per call. My goal is to get all the computer details at once.

stevewood
Honored Contributor II
Honored Contributor II

Ah, yes, that is pretty clear when you read the subject closer... 😎

Short of using a script with a loop to cycle through each computer (which could be a lot depending on # of endpoints), the easiest way to do this is probably with an Advanced Search. Setup the search to display exactly what you want and then call the search via API. Or set it up to be a report that is emailed out.

{{url}}/JSSResource/advancedcomputersearches/id/<id>

mm2270
Legendary Contributor III

This can be done if you create and save a Computer Advanced search and pull that in the API rather than other resources. The trick is to create a saved advanced search with either no criteria, or criteria that filters out the Macs you are interested in, and more importantly, add the columns of data you're interested in, such as User,  Computer Name, Operating System, Last Inventory Update and Last Check-in like you mention above.

Then in the API you can call that advanced search using the advancedcomputersearches API resource
 https://your.jamf.server/JSSResource/advancedcomputersearches/id/<id>

You'll need to parse the output in your script, but passing the result through xmllint like | xmllint --format - should make the XML structured at least.

Edit: Whoops! I didn't see @stevewood 's post above that basically suggested the same thing. So in short, I agree with him 😉 That's the best option to use when talking about the API.

tonystonks
New Contributor II

Thanks guys ! You made my day!

Hope your days are doing great too.

 

Folks,

with the upcoming shutdown of BasicAuth and the classic API,

How can this be accomplished in the new JAMF Pro API?
I'm struggling to find a means to get all this info in one pull.

stevewood
Honored Contributor II
Honored Contributor II

The Classic API is not going away until the Jamf Pro API has full parity. True, Basic Auth is being deprecated this year, but you can simply change over to using token auth in your scripts. Rich Trouton has a great blog post on how to get a bearer token:

https://derflounder.wordpress.com/2022/01/05/updated-script-for-obtaining-checking-and-renewing-bear...