Share Your Automox API Experience

Disclaimer: I’ve never really utilized API keys for data requests until now.
My API Use Case: Collect all server OS details including policies, users, and groups.

This is a great tool if you want detailed data from your Automox environment!

After reviewing the API Documentation for Automox I learned the types of API commands I could run and quickly realized I needed a way easily understand what’s in a .json file and how to read it.

I haven’t work with a .json file before, but after some research I found Postman which allowed me to run API requests from and easily download a .json - which ended up converting to an excel spreadsheet. The spreadsheet is so well organized and now I can easily vlookup what I need on a smaller separate work task.

It was an interesting first experience using an API key and Get requests but I felt it was successful in collecting everything I needed. I’m sure others could do this type of work in their sleep but it’s another wrench in the toolbox for me.

Anyone else want to share their thoughts and experiences using the API?

-Chris Frieberg

3 Likes

We use the API quite extensively here. We use LogicMonitor to poll all kinds of data from the Automox API so we can alert on any changes and track historical data.

For example, we monitor the agent connection status on every device in Automox. Quite frequently devices seem to become disconnected, so now we get alerts automatically when this happens allowing us to address the issue quickly. Using the API to monitor the update source status and WMI status from Automox is also useful for troubleshooting purposes.

We also monitor things like the pending update count so we can see how this value changes over time during patching windows. Along the same lines, we’ve used the API to automatically post updates to a slack channel as updates are installed for an organization which can be useful for keeping a pulse on the patching as it happens.

I’m curious to know how others are using the API.

1 Like

Thanks for starting this topic @cfrieberg. Would either of you be up for sharing any of the code you use for your API calls, so that others can try it out in their environment?

I needed to get an accurate software inventory for my environment, so I wrote this PowerShell script. It might run faster in another language, and you may have issues if your environment has over 5,000 devices to poll.

$apiKey = Read-Host -Prompt "Input Automox API Key"
$headers = @{ "Authorization" = 'Bearer ' + $apiKey }

#Get details for all devices
$org = Read-Host -Prompt "Input Org Number"
$uri = "https://console.automox.com/api/servers?o=" + $org + "&l=600&p=0"
$dvcs = Invoke-RestMethod -Uri $uri -Headers $headers

#build Device List
$dvcList = New-Object System.Collections.ArrayList
for ($i = 0; $i -lt $dvcs.results.Length; $i+=1){
    $dvcList.Add($dvcs.results[$i].id)}
    
#build Table containing software details and device details
#$uri = "https://console.automox.com/api/servers/{id}/packages"
$swTable = New-Object System.Collections.ArrayList
foreach ($dvc in $dvcs.results){
    #make web request for each device's software
    $uri = 'https://console.automox.com/api/servers/' + $dvc.id.ToString() + '/packages'
    $dvcSW = Invoke-RestMethod -Uri $uri -Headers $headers
    foreach ($sw in $dvcSW) {
        #ignore WindowsUpdate and WindowsHotfix installs
        if ($sw.repo -notin @('WindowsUpdate', 'WindowsHotfix')) {
            $null = $swTable.Add([PSCustomObject]@{
                display_name = $sw.display_name; 
                Name = $sw.name; 
                version = $sw.version;
                installed = $sw.installed
                Repo = $sw.repo; 
                dvc = $dvc.name; 
                dvc_ip=($dvc.ip_addrs|Select -ExpandProperty $_).ToString()
                })
            }
        }
    }
#generate Output File
$date = Read-Host -Prompt "Input Date (ddMMMyy)"
$swTable | Sort-Object -Property display_name | Export-Csv -Path ('C:\projects\SWInv_' + $date) -NoTypeInformation

Hope this helps someone else! :smile:

1 Like

Looks nice. Have you looked at the orgs/packages api? You can avoid looping over devices then, and (I think) get this in a single api call. It admittedly has some issues in larger orgs at the moment, but that will be getting optimized in the near-ish future (so look out for that, if it doesn’t work for you currently)

I tried using the single call, but it only gave me 5 packages across my org, which I knew was wrong.

That is very curious. Would you be willing to share what you used before? (I don’t mean to distract from your solution, I’m just curious!). If you copied it straight off the documentation page, the example has an optional parameter in it which might limit the results.

Here is what I used: [org# redacted]

$uri = "https://console.automox.com/api/orgs/{org#}/packages?awaiting=0&includeUnmanaged=0"
$invSW = Invoke-RestMethod -Uri $uri -Headers $headers
$invSW | Export-Csv "C:\projects\SWInv_14Jan20.csv" -NoTypeInformation

Thanks for sharing! I think the awaiting=0 is probably what caused the small return, that would limit the response to pending packages only. You can remove that parameter entirely, and see if it works for your use case. Also, welcome to the community!

2 Likes

Yep! That did it. It’s much more efficient when you write 3 lines :grin:

$uri = "https://console.automox.com/api/orgs/{id}/packages?"
$invSW = Invoke-RestMethod -Uri $uri -Headers $headers
$invSW | Export-Csv "C:\projects\SWInv.csv" -NoTypeInformation
3 Likes