NAME
WWW::Hetzner::Cloud - Perl client for Hetzner Cloud API
VERSION
version 0.102
SYNOPSIS
use WWW::Hetzner::Cloud;
my $cloud = WWW::Hetzner::Cloud->new(
token => $ENV{HETZNER_API_TOKEN},
);
# List servers
my $servers = $cloud->servers->list;
# Create server
my $server = $cloud->servers->create(
name => 'my-server',
server_type => 'cx23',
image => 'debian-13',
location => 'fsn1',
ssh_keys => ['my-key'],
);
# Delete server
$cloud->servers->delete($server->{id});
DESCRIPTION
This module provides access to the Hetzner Cloud API for managing cloud servers, DNS zones, networks, volumes, and other resources.
RESOURCES
Actions
actions - Async job objects (WWW::Hetzner::Action) returned by every mutating call below; poll status or block with
->wait
Compute
servers - Cloud servers (create, delete, power on/off, reboot, rebuild, rescue)
server_types - Available server types
images - OS images
isos - ISO images that can be attached to a server
ssh_keys - SSH keys
placement_groups - Placement groups for server distribution
Networking
networks - Private networks with subnets and routes
firewalls - Firewall rules and application
floating_ips - Reassignable public IPs
primary_ips - Primary IPs for servers
load_balancers - Load balancers with targets and services
load_balancer_types - Available load balancer types
Storage
volumes - Block storage volumes
DNS
zones - DNS zones and records
Security
certificates - TLS certificates (managed or uploaded)
Info
locations - Locations (fsn1, nbg1, hel1, ash, hil, sin)
datacenters - Datacenters
pricing - Current price list (a single object, not a list)
costs - Current running cost of the project (method, see "costs")
token
Hetzner Cloud API token. Defaults to HETZNER_API_TOKEN environment variable.
base_url
Base URL for the Cloud API. Defaults to https://api.hetzner.cloud/v1.
servers
Returns a WWW::Hetzner::Cloud::API::Servers instance for managing cloud servers.
actions
Returns a WWW::Hetzner::Cloud::API::Actions instance for reading Cloud actions. Actions (WWW::Hetzner::Action objects) are the async job objects that mutating calls across every resource in this class return -- this accessor is how one is looked up or polled directly by id, independent of the resource that created it.
server_types
Returns a WWW::Hetzner::Cloud::API::ServerTypes instance for listing server types.
images
Returns a WWW::Hetzner::Cloud::API::Images instance for listing OS images.
isos
Returns a WWW::Hetzner::Cloud::API::ISOs instance for listing ISO images.
ssh_keys
Returns a WWW::Hetzner::Cloud::API::SSHKeys instance for managing SSH keys.
locations
Returns a WWW::Hetzner::Cloud::API::Locations instance for listing locations.
datacenters
Returns a WWW::Hetzner::Cloud::API::Datacenters instance for listing datacenters.
Deprecated: Hetzner removed the datacenters endpoint, so every method of the returned controller dies with the API error 410 Gone (deprecated_api_endpoint). The controller is kept for backward compatibility only; use WWW::Hetzner::Cloud::API::Locations instead.
zones
Returns a WWW::Hetzner::Cloud::API::Zones instance for managing DNS zones.
volumes
Returns a WWW::Hetzner::Cloud::API::Volumes instance for managing block storage volumes.
networks
Returns a WWW::Hetzner::Cloud::API::Networks instance for managing private networks.
firewalls
Returns a WWW::Hetzner::Cloud::API::Firewalls instance for managing firewalls.
floating_ips
Returns a WWW::Hetzner::Cloud::API::FloatingIPs instance for managing floating IPs.
primary_ips
Returns a WWW::Hetzner::Cloud::API::PrimaryIPs instance for managing primary IPs.
load_balancers
Returns a WWW::Hetzner::Cloud::API::LoadBalancers instance for managing load balancers.
load_balancer_types
Returns a WWW::Hetzner::Cloud::API::LoadBalancerTypes instance for listing load balancer types.
certificates
Returns a WWW::Hetzner::Cloud::API::Certificates instance for managing TLS certificates.
placement_groups
Returns a WWW::Hetzner::Cloud::API::PlacementGroups instance for managing placement groups.
pricing
Returns a WWW::Hetzner::Cloud::API::Pricing instance for reading the current price list. Pricing is a single object rather than a collection, so that controller only has get.
costs
my $costs = $cloud->costs;
my $live = $cloud->costs(label_selector => 'env=live', price => 'net');
printf "%.4f %s/h, %.2f %s/month (%s)\n",
$live->{totals}{hourly}, $live->{currency},
$live->{totals}{monthly}, $live->{currency}, $live->{price};
Returns what the project's servers (any status, plus backup surcharge), volumes, primary IPs, floating IPs and load balancers currently cost per hour and per month, priced per location from the current price list. Prices are gross unless price => 'net' is passed; label_selector filters every list request. Only reads. See WWW::Hetzner::Cloud::Costs for the returned structure and how hourly prices are derived where the price list has none.
DNS EXAMPLE
# List DNS zones
my $zones = $cloud->zones->list;
# Create a zone
my $zone = $cloud->zones->create(name => 'example.com');
# Add DNS records
my $rrsets = $zone->rrsets;
$rrsets->add_a('www', '203.0.113.10');
$rrsets->add_cname('blog', 'www.example.com.');
$rrsets->add_mx('@', 'mail.example.com.', 10);
LOGGING
WWW::Hetzner::Cloud uses Log::Any for logging via WWW::Hetzner::Role::HTTP. This allows you to integrate with any logging framework of your choice.
Log Levels Used
debug - Request URLs, bodies, response status
info - Successful API calls (method, path, status)
error - API errors before croak
Enabling Logging
By default, logs are discarded. To see them, configure a Log::Any adapter:
# Simple: output to STDERR
use Log::Any::Adapter ('Stderr');
# With minimum level
use Log::Any::Adapter ('Stderr', log_level => 'debug');
# To a file
use Log::Any::Adapter ('File', '/var/log/hetzner.log');
# Integration with Log::Log4perl
use Log::Log4perl;
Log::Log4perl->init('log4perl.conf');
use Log::Any::Adapter ('Log4perl');
# Integration with Log::Dispatch
use Log::Dispatch;
my $dispatcher = Log::Dispatch->new(...);
use Log::Any::Adapter ('Dispatch', dispatcher => $dispatcher);
See Log::Any::Adapter for all available adapters.
HTTP Debugging with LWP::ConsoleLogger
When using the default WWW::Hetzner::LWPIO backend, you can enable full HTTP request/response logging with LWP::ConsoleLogger::Everywhere. No code changes required — just load the module:
# In your script
use LWP::ConsoleLogger::Everywhere;
# Or from the command line
perl -MLWP::ConsoleLogger::Everywhere your_script.pl
This shows complete request and response headers, status codes, and decoded response bodies in a readable table format. Useful for debugging API issues without adding any code.
SEE ALSO
WWW::Hetzner, WWW::Hetzner::Role::HTTP, WWW::Hetzner::Action, WWW::Hetzner::Cloud::API::Actions
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-www-hetzner/issues.
IRC
Join #kubernetes on irc.perl.org or message Getty directly.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.