API usage ideas
In similar spirit to the shared script library, I would love to see a central repository for sharing ideas on how the API is being used in various environments. I am good with technical, but sometimes my creativity is lacking.
What are some of your best API usage ideas?
Comments
-
I have used the API with Powershell scripting in the past to design reports and to circumvent some limitations of Atera (ex. Needing an email to add contact). I have also seen throughout the discussions and other forums that a lot of people have built custom wallboards using Micorosft's Power BI. I have began working with Power BI and once I have a good feel for how it works I'd be happy to share with everyone else some instructional documentation. If anyone would like to be included when I get this completed, feel free to send me a message.
5 -
I like and support this suggestion.
I also started using it to circumvent some of the limitations in the system.
Even just some basic example scriptlets for various languages like PHP and Powershell would have been an amazing leg up. I do think that the API help site was very helpful once I figured it out.
I found the API fairly hard to get into (not a hardcore programmer here).
The lack of simple examples made it hard for me and took forever with trial and error before I got some working code. I have posted a couple of examples in the forums so that others can build on them.
Once I got some working code it was easier to play around with it.Would love to see what people can share so that we can all grow.
1 -
Messed around with Power BI for about 30 minutes today just trying to learn how to query and was able to come up with a query that returns all tickets. If anyone has ideas for wallboards or whatnot let me know :) @MJones if you want a walkthrough on how this works I would be happy to send you documentation on how to connect Atera and Power BI
4 -
Haven't gotten into PowerBI yet, but hear it's pretty great.
Better yet make a post and we can all see and share :)
3 -
Made the post
1 -
Found this if anyone wants examples: https://support.atera.com/hc/en-us/articles/219083397
1 -
Wow, looks like they spruced it up a little last time I looked!
Here was my sample for PowerShell if anyone finds it useful:
$api_Key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" #Standard Header
$headers = @{
'X-API-KEY' = $api_key
} #Get All Agents
$machine_info = Invoke-RestMethod -Headers $headers -Uri https://app.atera.com/api/v3/agents/ | Select-Object -ExpandProperty items Write-Output $machine_info #Get Local Agent Info By Name
$machine_info = Invoke-RestMethod -Headers $headers -Uri https://app.atera.com/api/v3/agents/machine/$env:computername | Select-Object -ExpandProperty items Write-Output $machine_info #Get Agent Info by Agent ID
$agentID = 4 $machine_info = Invoke-RestMethod -Headers $headers -Uri https://app.atera.com/api/v3/agents/$agentID Write-Output $machine_info #Create an alert from a local machine
#Get the local agent information from the API
$machine_info = Invoke-RestMethod -Headers $headers -Uri https://app.atera.com/api/v3/agents/machine/$env:computername | Select-Object -ExpandProperty items #Build the alert
$title = "Incorrect Time"
$additional_info = "The agents time is off by more than 5 minutes"
$severity = "Warning" #Available Options: ['Information', 'Warning', 'Critical']
$alert_category = "General" #Available Options: ['Hardware', 'Disk', 'Availability', 'Performance', 'Exchange', 'General'] $postParams = @{
DeviceGuid = $machine_info.DeviceGuid;
CustomerID = $machine_info.CustomerID;
Title = $title;
Severity = $severity;
AdditionalInfo = $additional_info;
AlertCategoryID = $alert_category
} #Create the Alert
Invoke-RestMethod -Headers $headers -Uri https://app.atera.com/api/v3/alerts -Method POST -Body $postParams #Create a ticket
#Build the ticket
$ticket_title = "API Test"
$ticket_description = "Ticket to test the API"
$end_user_id = "1" #Target a specific user $postParams = @{
TicketTitle = $ticket_title;
Description = $ticket_description;
EndUserID = $end_user_id
} #Create the ticket
Invoke-RestMethod -Headers $headers -Uri https://app.atera.com/api/v3/tickets -Method POST -Body $postParams3 -
@MJones thank you for this. This really helps give me a start with the API. This is uncharted territory for me and I’m trying to lay some groundwork for our new ERP implementation kicking off soon. I want to leverage the API to initiate tickets based on workflows in our new system and wasn’t sure where to start.
3 -
Between what I posted and the API site, you should be able to get whatever you need from the API. It's not too bad at all once you have some formats to work off of.
2 -
It's not super fancy, but at least you don't have to figure out the quirky syntax to get it talking.
1 -
I hope this will be usefull to you guys
It's a Powershell function that get all of your Atera Agents (not just the first 20)
The agent are returned as a list of object that you can easily use or export
(It's pretty fast, arround 30 second to get 3000 agents, tested on Powershell 5 and 7)$ATERA_APIKEY = "YOUR_API_KEY"
function Get-AllAteraAgents { param ( [Parameter(Mandatory)] [string]$apiKey ) Write-Host "FETCHING ATERA AGENTS" -f Blue $rawList = New-Object System.Collections.ArrayList $getParam = @{ Headers = @{ "X-API-KEY" = "$($apiKey)" "Accept" = "application/json" } Body = @{ page = 1 itemsInPage = 50 } Method = "GET" URI = "https://app.atera.com/api/v3/agents" } $totalPages = (Invoke-RestMethod @getParam).totalPages Write-Host "NUMBER OF PAGES TO GET: $($totalPages)" -f Blue for ($page = 1; $page -le $totalPages; $page++) { # sleep -Milliseconds 100 Write-Progress -Activity "Processing Agents" -Status "$page out of $totalPages pages processed" -PercentComplete (($page / $totalPages) * 100) $body = @{ page = $page itemsInPage = 50 }
# ADDRANGE IS USED INSTEAD OF ADD TO FLATTEN THE ARRAY $rawList.AddRange((Invoke-RestMethod -Headers $getParam.Headers -Body $body -Uri "https://app.atera.com/api/v3/agents").items) 1>$null } Write-Progress -Activity "Processing Agents" -Completed Write-Host "TOTAL NUMBER OF ATERA AGENTS: $($rawList.Count)" -f Blue return $rawList } ### EXEMPLE USAGE $agentsList = Get-AllAteraAgents -apiKey $ATERA_APIKEY # VISUALIZE WITH OUT-GRIDVIEW $agentsList | Out-GridView # EXPORT ALL THE AGENTS TO A CSV FILE $agentsList | Export-csv -Path ".\AteraAgentExport_$(Get-Date -F "dd-MM-yyyy").csv" -Delimiter ";"4 -
Thank you to @mjones and @support-info for sharing these, very useful.
My intention is to try and build a ticket export method using the API to pull tickets for all contacts within a company, plus ticket comments (perhaps!) to export out to CSV… wish me luck.Of course should @rmiller or anyone else happens to have this or something approaching this please let me know :)
3 -
Once you've got the data it's really easy to play with since it comes in JSON format.
1 -
Ticket exporting via API
I found that I didn't need to obtain the contacts first as the API allows collection from a company. This code retrieves the tickets for a specific customerID
We've been using Atera since October '23, so around 6 months and this script takes around 30 seconds to process those 180 pages of data stripping out the html and css tags from the comments before presenting and saving as CSV.This achieves what I needed so I will probably not continue to collect each ticket comment.
Sharing here as it may be useful for someone else.
$ATERA_APIKEY = "?????????????????" function Get-AllAteraTickets {
param (
[Parameter(Mandatory)]
[string]$apiKey,
[Parameter(Mandatory)]
[string]$customerId
)
Write-Host "FETCHING ATERA TICKETS FOR CUSTOMER $customerId" -f Blue
$rawList = New-Object System.Collections.ArrayList $getParam = @{
Headers = @{
"X-API-KEY" = "$($apiKey)"
"Accept" = "application/json"
}
Method = "GET"
URI = "https://app.atera.com/api/v3/tickets"
}
$response = Invoke-RestMethod @getParam
$totalPages = $response.totalPages
Write-Host "NUMBER OF PAGES TO GET: $($totalPages)" -f Blue
for ($page = 1; $page -le $totalPages; $page++) {
Write-Progress -Activity "Processing Tickets" -Status "$page out of $totalPages pages processed" -PercentComplete (($page / $totalPages) * 100)
$body = @{
page = $page
itemsInPage = 50
customerId = $customerId
}
$rawList.AddRange((Invoke-RestMethod -Headers $getParam.Headers -Body $body -Uri "https://app.atera.com/api/v3/tickets").items) 1>$null
}
Write-Progress -Activity "Processing Tickets" -Completed
Write-Host "TOTAL NUMBER OF ATERA TICKETS: $($rawList.Count)" -f Blue
return $rawList } function Clean-HTML {
param (
[string]$text
)
$text = [System.Text.RegularExpressions.Regex]::Replace($text, '<[^>]+>', '')
$text = $text -replace '\s+', ' '
$text = $text.Trim()
return $text
} EXAMPLE USAGE $ticketsList = Get-AllAteraTickets -apiKey $ATERA_APIKEY -customerId "4" Clean specified fields $ticketsList | ForEach-Object {
$.FirstComment = Clean-HTML -text $.FirstComment
$.LastEndUserComment = Clean-HTML -text $.LastEndUserComment
$.LastTechnicianComment = Clean-HTML -text $.LastTechnicianComment
} VISUALIZE TICKETS WITH OUT-GRIDVIEW $ticketsList | Out-GridView EXPORT TICKETS TO A CSV FILE $ticketsList | Export-csv -Path ".\AteraTicketExport_$(Get-Date -F "dd-MM-yyyy").csv" -Delimiter ";"3 -
you guys are amazing - thanks for sharing your samples! I'm just getting into using the API today with powershell and these examples have been a huge help. Thanks!
1 -
Great contributions going on here, you guys are the best 🤩
1 -
Hello guys! I'm new here and searching ways how to retireve alerts using Atera API. I found documentation, but I can't understand if I could specify time for a request to not retrieving alerts which I already requested. Is it possible? Thank you in advance!
0 -
You can GET all of the alerts and then filter based on date\time in the "Created" field or you can GET a specific alert based on the ID.
https://app.atera.com/apidocs#!/Alert/Alert_Get0
Topics
- All Topics
- 42 Getting started
- 26 Read before posting
- 8 Meet and greet
- 257 General
- 71 News and announcements
- 2 Swag
- 1 Roadmap updates
- 83 Resources
- 12 Knowledge Base
- 17 Webinars
- 1 Shared Script Library
- 2 Blog
- 21 Pro Tips
- 28 Got an idea?
- 3 Atera Academy
- 2 ActionAI
- 1 Copilot
- 142 Remote Monitoring and Management
- 85 Remote Monitoring
- 28 Patch Management
- 107 Professional Services Automation
- 65 Helpdesk
- 17 Billing
- 22 Reporting
- 41 Integrations & add-ons
- 22 Integrations
- 11 Add-ons
- 108 Scripting and automations
- 62 Scripts
- 32 Automations