Use this when scripting or integrating with vSphere, Hyper-V, libvirt or Proxmox through their APIs, or when an API call fails or returns unexpected data.
APIs
Hypervisor APIs (vSphere API, Hyper-V WMI/PowerShell, libvirt, Proxmox REST, cloud provider APIs) expose VM, network and storage operations to scripts and tools; authenticate with a scoped service account and use the API's task status to confirm results.
1. APIs enable automation and integration.
2. Use tokens with minimal privileges.
3. Verify TLS.
4. Rate limits and timeouts.
5. Log API use.
client → authenticated API → management service
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Checks Verify boundary
- Token works (
curlreturns 200). - Permissions limited to needed paths.
- Task status polled until complete.
Step 2 Common mistakes Narrow the fault
- Using admin accounts for API scripts instead of scoped tokens.
- Ignoring asynchronous tasks — check the task result, not only the API response.
- Not handling rate limits and session expiry.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- HTTP 200 on a task ≠ the task succeeded.
- API permissions follow the service account's roles.
- API versions differ between platform releases.
curl -s -H 'Authorization: PVEAPIToken=<user>@pam!<id>=<secret>' https://<host>:8006/api2/json/version— Proxmox APIInvoke-RestMethod https://vcenter/api/session -Method Post -Credential $c— vCenter RESTvirsh -c qemu+ssh://<host>/system list— libvirt remote API
ReferenceWhy it matters1 section · depth on demand
In depth
Virtualization APIs:
| Platform | API | Access |
|---|---|---|
| vSphere | REST (vSphere Automation API), SOAP (vim) | PowerCLI, govc, pyVmomi, Terraform |
| Hyper-V | WMI/CIM (root\virtualization\v2), PowerShell module | PowerShell remoting, WAC |
| Proxmox VE | REST https://host:8006/api2/json | pvesh, API tokens, proxmoxer, Terraform |
| libvirt | libvirt API (C, Python bindings), virsh | SSH/TLS transports |
pvesh get /cluster/resources --type vm --output-format json
curl -sk -H 'Authorization: PVEAPIToken=automation@pve!ci=<secret>' https://pve1:8006/api2/json/nodes
govc vm.info -json app01
ReferenceImportant terms & boundaries2 sections · depth on demand
APIs per platform
Example calls
curl -k -H 'Authorization: PVEAPIToken=user@pam!automation=TOKEN' https://pve:8006/api2/json/nodes
Invoke-RestMethod -Uri https://vcenter/api/vcenter/vm -Headers @{'vmware-api-session-id'=$sid}
Documented example, not captured output.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Automation → APIs. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://libvirt.org/html/index.html · confidence 94%