NAME

WWW::Hetzner::Robot::API::Traffic - Hetzner Robot Traffic API

VERSION

version 0.002

SYNOPSIS

my $robot = WWW::Hetzner::Robot->new(...);

# Query daily traffic for an IP
my $traffic = $robot->traffic->query(
    type => 'day',
    from => '2024-01-01T00',
    to   => '2024-01-02T00',
    ip   => '1.2.3.4',
);

# Query monthly traffic for multiple IPs
my $traffic = $robot->traffic->query(
    type => 'month',
    from => '2024-01-01',
    to   => '2024-02-01',
    ip   => ['1.2.3.4', '5.6.7.8'],
);

# Query with single_values for hourly breakdown
my $traffic = $robot->traffic->query(
    type          => 'day',
    from          => '2024-01-01T00',
    to            => '2024-01-02T00',
    ip            => '1.2.3.4',
    single_values => 1,
);

DESCRIPTION

Query traffic statistics for IPs and subnets.

query

my $traffic = $robot->traffic->query(%params);

Query traffic statistics. Returns hashref with traffic data.

Parameters:

type (required)

Type of traffic query: day, month, or year.

from (required)

Start date/time. Format depends on type:

  • day: YYYY-MM-DDTHH (e.g., 2024-01-01T00)

  • month: YYYY-MM-DD (e.g., 2024-01-01)

  • year: YYYY-MM (e.g., 2024-01)

to (required)

End date/time. Same format as from.

ip

Single IP address or arrayref of IP addresses.

subnet

Single subnet or arrayref of subnets.

single_values

If true, returns data grouped by hour/day/month.

Response structure:

{
    type => 'day',
    from => '2024-01-01T00',
    to   => '2024-01-02T00',
    data => {
        '1.2.3.4' => {
            in  => 10.5,   # GB inbound
            out => 25.3,   # GB outbound
            sum => 35.8,   # GB total
        },
    },
}

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.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.