Example of API call with pagination limits

  • 16 December 2020
  • 0 replies

Userlevel 7

I’ve taken @jarod.smilkstein’s code from here.


There’s 3 things to change in this code to make it work:



  2. put in your API key
  3. put in your orgID
  4. set the $limit variable to the size you want, with a maximum of 500




This code will pull down all your device info via the https://console.automox.com/api/servers

API call, but you can sub that out for whatever info you’re wanting to pull. The data is saved to a csv, but you can also do manipulation to the $data object in the script first before outputting any data.



You can use this example code to update any of your existing scripts that were created prior to the API limits.



$apiKey = 'YOUR_API_KEY'

$orgID = 'YOUR_ORG_ID'

$page = 0

$limit = 5

$data = @()

while($true) {

$uri = "https://console.automox.com/api/servers?o=$orgID&api_key=$apiKey&l=$limit&p=$page"

$resp = (Invoke-WebRequest -Method GET -Uri $uri -UseBasicParsing).Content | ConvertFrom-Json | Select-Object results

$data += $resp.results

if($resp.results.count -lt $limit) {



$page += 1


$data | Export-Csv -Path .\AutomoxAPI_Export.csv -NoTypeInformation -Force

0 replies

Be the first to reply!