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.
3 -
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
3 -
Haven't gotten into PowerBI yet, but hear it's pretty great.
Better yet make a post and we can all see and share :)
2 -
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 $postParams1 -
@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.
2 -
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.
1 -
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 ";"2
Topics
- All Topics
- 31 Getting started
- 20 Read before posting
- 7 Meet and greet
- 156 General
- 42 News and announcements
- 40 Resources
- 7 Knowledge Base
- 7 Webinars
- 1 Shared Script Library
- Blog
- 4 Pro Tips
- 21 Got an idea?
- 93 Remote Monitoring and Management
- 67 Remote Monitoring
- 18 Patch Management
- 64 Professional Services Automation
- 42 Helpdesk
- 7 Billing
- 14 Reporting
- 25 Integrations & add-ons
- 16 Integrations
- 6 Add-ons
- 69 Scripting and automations
- 43 Scripts
- 22 Automations