Skip to main content
Question

Need API response to work on my script changes using V3 APIs to V4 APIs

  • November 25, 2025
  • 1 reply
  • 17 views

Konapalli
Forum|alt.badge.img+1

Hi Folks,

am updating my script for creating a snapshot and store in file device am currently using V3 prism central APIs and want to migrate to use V4 APIS. someone help me with the sample response of APIS in V3 and V4 for List VMS.

V4: https://{pc-ip}:9440/api/vmm/v4.1/ahv/config/vms
V2 prism element:  $CLUSTER/PrismGateway/services/rest/v2.0/vms → am using this currently.

 

any dummy VM response is fine just want to estimate the changes and complexity.

1 reply

Forum|alt.badge.img
  • Voyager
  • November 25, 2025

This is what I use in PowerShell to get the list of AHV VMs associated with PC:

#####Vars
$pc = Read-Host -Prompt "Enter PC FQDN/IP"
$creds = Get-Credential


####Get VM Information > All AHV VMs
Write-Host "$pc - Getting VM Information" -ForegroundColor Blue

$pc_cluster_vms = New-Object System.Collections.ArrayList
$page = 0
do{
#Create URI#
$api_endpoint = "/api/vmm/v4.0/ahv/config/vms?`$page=$page&`$limit=100"
$uri = "https://" + $pc + ":" + 9440 + $api_endpoint

#Create Header#
$headers = [ordered]@{}
$headers."Accept" = "application/json"
$headers."Content-Type" = "application/json"

#Create Parameter Splatting
$param = [ordered]@{}
$param.Uri = $uri
$param.Method = "Get"
$param.Headers = $headers
$param.Authentication = "Basic"
$param.Credential = $creds
$param.SkipCertificateCheck = $true

#API Call# >> Get VM Information
$results = Invoke-RestMethod @param

if($results.count -gt 0){
$pc_cluster_vms.AddRange($results.data) | Out-Null
}

$page++
}until(($results.metadata.links | Where-Object {$_.rel -eq "self"}).href -eq ($results.metadata.links | Where-Object {$_.rel -eq "last"}).href)

The v4 API can only pull so many VMs at once (maximum of 100). You have to loop through the paginated responses. And, there are two API calls that pull VM information. One for AHV (as shown above) and one for ESX.

 

The v4 API documentation lists sample responses: https://developers.nutanix.com/api-reference?namespace=vmm&version=v4.1#tag/Vm/operation/listVms

If you click on the link and search the page for “Response samples” you will be able to see them. From what I have found the documentation is pretty accurate:

 

There are several major differences between the v2 and v4 APIs. One of the biggest is that you have to make a separate API call to get metrics/stats (that seems to be outside of the scope of your question so that should be fine.)