Go client with types and tests for the Proxmox-VE REST API
Find a file
Samuel Hierholzer d02223ff87
feat: add alias field to VNet and VM Monitor Endpoint (#253)
* feat: add alias field to VNet

* feat: Add virtual machine monitor endpoint

* feat: Update VirtualMachineConfig when Pinging

* fix: reset VirtualmachineConfig on Ping, in case fields got deleted

* feat: Add vm.DeleteSnapshot endpoint
2026-04-02 23:05:42 -07:00
.github/workflows bumping golang version in mod file (#238) 2026-01-21 14:36:24 -07:00
examples/term-and-vnc fixing unmarshalling bug with new custom storage unmarshaller (#243) 2026-02-13 16:43:21 -07:00
mage bumping golang version in mod file (#238) 2026-01-21 14:36:24 -07:00
tests feat: add alias field to VNet and VM Monitor Endpoint (#253) 2026-04-02 23:05:42 -07:00
.gitignore updating mage to use aliases 2023-01-16 00:55:19 -07:00
.golangci.yaml bumping golang version in mod file (#238) 2026-01-21 14:36:24 -07:00
access.go update domain.Sync method to use POST /access/domains/{realm}/sync API path (#246) 2026-04-02 22:52:24 -07:00
access_test.go feat: Enhance support for /access (#125) 2024-03-05 13:36:15 -07:00
build.go adding github actions 2023-01-14 08:25:21 -07:00
ceph.go WIP: feat: Implement api2/json/cluster/ceph/status endpoint (#186) 2025-03-19 15:39:34 -07:00
ceph_test.go WIP: feat: Implement api2/json/cluster/ceph/status endpoint (#186) 2025-03-19 15:39:34 -07:00
cluster.go bumping golang version in mod file (#238) 2026-01-21 14:36:24 -07:00
cluster_firewall.go Fix various linting warnings (#164) 2024-09-26 12:38:38 -07:00
cluster_firewall_test.go adding cluster firewall coverage (#236) 2026-01-21 12:40:33 -07:00
cluster_sdn.go bumping golang version in mod file (#238) 2026-01-21 14:36:24 -07:00
cluster_test.go feat: add alias field to VNet and VM Monitor Endpoint (#253) 2026-04-02 23:05:42 -07:00
container_config.go fix typos in function comments (#168) 2024-10-07 14:48:05 -07:00
containers.go Fix lxc/reize by using PUT instead of POST (#247) 2026-03-19 06:34:37 -07:00
containers_test.go bumping golang version in mod file (#238) 2026-01-21 14:36:24 -07:00
go.mod bumping golang version in mod file (#238) 2026-01-21 14:36:24 -07:00
go.sum bumping golang version in mod file (#238) 2026-01-21 14:36:24 -07:00
LICENSE adding codecov and license 2021-08-01 21:26:23 -07:00
logger.go Fix a few warnings raised by Goland 2023-08-24 09:03:39 +02:00
logger_test.go adding logger tests 2023-08-31 00:32:35 -07:00
magefile.go fixing gofmt issues and adding more badges 2023-08-22 08:45:18 -07:00
nodes.go adding more test coverage (#235) 2026-01-21 12:20:32 -07:00
nodes_network.go Add listing of network interfaces by type (#201) 2025-06-14 09:10:52 -07:00
nodes_network_test.go adding pve9 mocks (#234) 2026-01-21 07:51:51 -07:00
nodes_test.go bumping golang version in mod file (#238) 2026-01-21 14:36:24 -07:00
options.go rework access to use options, added permissions 2023-08-19 20:40:47 -07:00
options_test.go rework access to use options, added permissions 2023-08-19 20:40:47 -07:00
pools.go bumping golang version in mod file (#238) 2026-01-21 14:36:24 -07:00
pools_test.go Add context support 2023-10-25 17:45:33 +02:00
proxmox.go fix: session expiration time (#239) 2026-03-19 06:40:06 -07:00
proxmox_test.go adding pve9 mocks (#234) 2026-01-21 07:51:51 -07:00
README.md Fix link in README.md (#173) 2024-10-24 09:28:37 -07:00
storage.go Add import content type (#229) 2026-01-05 09:06:41 -07:00
storage_test.go fixing unmarshalling bug with new custom storage unmarshaller (#243) 2026-02-13 16:43:21 -07:00
tasks.go Fix various linting warnings (#164) 2024-09-26 12:38:38 -07:00
tasks_test.go adding more test coverage (#235) 2026-01-21 12:20:32 -07:00
types.go feat: add alias field to VNet and VM Monitor Endpoint (#253) 2026-04-02 23:05:42 -07:00
types_test.go adding StringOrFloat64 2023-08-09 12:00:42 -07:00
virtual_machine.go feat: add alias field to VNet and VM Monitor Endpoint (#253) 2026-04-02 23:05:42 -07:00
virtual_machine_config.go fix: vm merge devices (#232) 2026-01-20 21:46:04 -07:00
virtual_machine_config_test.go Implement custom UnmarshalJSON method for VirtualMachineConfig to handle device merging and tag parsing; add tests for merged maps population. (#250) 2026-03-19 06:16:22 -07:00
virtual_machine_test.go feat: add alias field to VNet and VM Monitor Endpoint (#253) 2026-04-02 23:05:42 -07:00

Proxmox API Client Go Package

Continuous Integration GitHub license GitHub issues GitHub release codecov Go Report Card Go Reference

Join the community to discuss ongoing client development usage, the proxmox API or tooling in the #go-proxmox channel on the Gophers Slack and see the self generated docs for more usage details.

Slack

A go client for Proxmox VE. The client implements /api2/json and inspiration was drawn from the existing Telmate package but looking to improve in the following ways...

  • Treated as a proper standalone go package
  • Types and JSON marshal/unmarshalling for all end points
  • Full Testing, unit testing with mocks and integration tests against an API endpoint
  • Configuration options when creating a client for flexible usage
  • Client logging for debugging within your code
  • Context support
  • Added functionality for better go tooling built on this library, some things we'd like
    • Boot VM from qcow URL, inspiration: Proxmox Linux Templates
    • Dynamic host targeting for VM, Proxmox lacks a scheduler when given VM params it will try and locate a host with resources to put it
    • cloud-init support via no-cloud ISOs uploaded to node data stores and auto-mounted before boot, inspiration quiso
    • Unattended XML Support via ISOs similar to cloud-init ideas
    • node/vm/container shell command support via KVM proxy already built into proxmox

Core developers are home lab enthusiasts working in the virtualization and kubernetes space. The common use case we have for Proxmox is dev stress testing and validation of functionality in the products we work on, we plan to build the following tooling around this library to make that easier.

Usage

Create a client and use the public methods to access Proxmox resources.

Basic usage with login with a username and password credential

package main

import (
	"context"
	"fmt"
	
	"github.com/luthermonson/go-proxmox"
)

func main() {
    credentials := proxmox.Credentials{
		Username: "root@pam", 
		Password: "12345",
    }
    client := proxmox.NewClient("https://localhost:8006/api2/json",
		proxmox.WithCredentials(&credentials),
    )
	
    version, err := client.Version(context.Background())
    if err != nil {
        panic(err)
    }
    fmt.Println(version.Release) // 7.4
}

Usage with Client Options

package main

import (
	"context"
	"crypto/tls"
	"fmt"
	"net/http"
	
	"github.com/luthermonson/go-proxmox"
)

func main() {
    insecureHTTPClient := http.Client{
        Transport: &http.Transport{
            TLSClientConfig: &tls.Config{
                InsecureSkipVerify: true,
            },
        },
    }
    tokenID := "root@pam!mytoken"
    secret := "somegeneratedapitokenguidefromtheproxmoxui"
    
    client := proxmox.NewClient("https://localhost:8006/api2/json",
        proxmox.WithHTTPClient(&insecureHTTPClient),
        proxmox.WithAPIToken(tokenID, secret),
    )
    
    version, err := client.Version(context.Background())
    if err != nil {
        panic(err)
    }
    fmt.Println(version.Release) // 6.3
}

Developing

This project relies on Mage for cross os/arch compatibility, please see their installation guide.

Unit Testing

Run mage test to run the unit tests in the root directory.

Integration Testing

To run the integration testing suite against an existing Proxmox API set some env vars in your shell before running mage testIntegration. The integration tests will test logging in and using an API token credentials so make sure you set all five env vars before running tests for them to pass.

Please leave no trace when developing integration tests. All tests should create and remove all testing data they generate then they can be repeatably run against the same proxmox environment. Most people working on this package will likely use their personal Proxmox VE home lab and consuming extra resources via tests will lead to frustration.

Bash

export PROXMOX_URL="https://192.168.1.6:8006/api2/json"
export PROXMOX_USERNAME="root@pam"
export PROXMOX_PASSWORD="password"
export PROXMOX_TOKENID="root@pam!mytoken"
export PROXMOX_SECRET="somegeneratedapitokenguidefromtheproxmoxui"

mage test:integration

Powershell

$Env:PROXMOX_URL = "https://192.168.1.6:8006/api2/json"
$Env:PROXMOX_USERNAME = "root@pam"
$Env:PROXMOX_PASSWORD = "password"
$Env:PROXMOX_TOKENID = "root@pam!mytoken"
$Env:PROXMOX_SECRET = "somegeneratedapitokenguidefromtheproxmoxui"

mage test:integration