Start monitoring today and get 20% off on your first invoice. Available on all Uptrends plans.

The following example accesses the Uptrends API and fetches the list of Uptrends' checkpoint locations.


# Specify your Uptrends login info here
$user = "james@galacticresorts.com"
$pass= "1234xxx"

# URI to the API method you want to execute
$uri = "https://api.uptrends.com/v3/checkpointservers"

# Compile the login info into credentials containing basic authentication
$passwordValue = ConvertTo-SecureString $pass -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($user, $passwordValue)

# Execute the request
$result = Invoke-RestMethod -Uri $uri -Method Get -Credential $cred -Headers @{ Accept = "application/json" }

That final statement puts the result in the `$result` variable. You can then continue working with that content. For example, to retrieve the IPv4 address for a specific checkpoint:


$result | Where-Object { $_.CheckPointName -eq 'Leicester, United Kingdom' } | Select IPAddress