Geo::IPinfo - Official Perl module to use ipinfo.io geolocation services


Version 1.0 - Initial release


Geo::IP provides an object-oriented perl interface to https://ipinfo.io geolocation services

A quick usage example:

    use Geo::IPinfo;

    my $token = "1234567";

    # if you have a valid token, use it
    my $ipinfo = Geo::IPinfo->new($token);

    # or, if you don't have a token, use this:
    # my $ipinfo = Geo::IPinfo->new();

    # return a hash reference containing all IP related information
    my $data = $ipinfo->info("");

    if (defined $data)   # valid data returned
      print "Information about IP\n";
      for my $key (sort keys %$data )
        printf "%10s : %s\n", $key, $data->{$key};
      print "\n";
    else   # invalid data obtained, show error message
      print $ipinfo->error_msg . "\n";

    # retrieve only city information of the IP address
    my $city = $ipinfo->field("", "city");

    print "The city of is $city\n";



Create an ipinfo object. The 'token' argument (string value) is optional.

If 'token' is specified, then it's used to overcome the default non-commercial limitation of 1,000 request/day (For more details, see https://ipinfo.io/pricing)


Returns a reference to a hash containing all information related to the IP address. In case of errors, returns undef, the error message can be retrieved with the function 'error_msg()'

The values returned are: ip, hostname, city, region, country, loc, org


Returns a reference to a hash containing only the geolocation related data. Returns undef in case of errors, the error message can be retrieved with the function 'error_msg'

It's usually faster than getting the full response using 'info()'

The values returned are: ip, loc, city, region, country

field(ip_address, field_name)

Returns a string with the contents of field_name for the specified IP address. Returns undef if the field is invalid

The possible values of 'field_name' are: ip, hostname, city, region, country, loc, org

error_msg( )

Returns a string containing the error message of the last operation, it returns an empty string if the last operation was successful


Ben Dowling, <ben at change.me>


Please report any bugs or feature requests to bug-geo-ipinfo at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Geo-IPinfo. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc Geo::IPinfo

You can also look for information at:



Copyright 2017 ipinfo.io.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at


Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.