GeoIP2...Country(3pm)

πŸ“¦
version 2.006002 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– GeoIP2::Record::Country β€” the country record, but make it cute πŸ’–

okay so bestie, welcome to the GeoIP2...Country(3pm) page, filed under User Contributed Perl Documentation. this is the whole vibe, let's go ✨

🌸 NAME 🌸

GeoIP2::Record::Country β€” this lil class holds all the country-level data that's associated with an IP address πŸ—ΊοΈπŸ’…

⭐ VERSION ⭐

version 2.006002 β€” yes queen, that's the one πŸ‘‘

πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole situation, copy-paste ready:

use 5.008;

use GeoIP2::WebService::Client;

my $client = GeoIP2::WebService::Client->new(
    account_id  => 42,
    license_key => 'abcdef123456',
);

my $insights = $client->insights( ip => '24.24.24.24' );

my $country_rec = $insights->country();
print $country_rec->name(), "\n";

literally so simple. you build a client, you ask for insights on an IP, you pull the country() record, and you print its name(). slay 🫢


🌈 DESCRIPTION 🌈

so this class contains the country-level data associated with an IP address. that's the whole job. no cap.

and listen β€” this record is returned by all the end points. every single one. main character record, honestly πŸ‘‘


✨ METHODS ✨

this class provides the following methods, and we're going through every single one because we don't skip πŸ’–

πŸ“ $country_rec->confidence()

returns a value from 0-100 indicating MaxMind's confidence that the country is correct. it's giving "how sure are we, on a scale" 🌸

heads up bestie: this attribute is only available from the Insights end point and the GeoIP2 Enterprise database. nowhere else. don't come for it elsewhere πŸ’€

🧚 $country_rec->geoname_id()

returns a geoname_id for the country. that's the id. the name-id. iconic.

this attribute is returned by all end points πŸ’œ

πŸŽ€ $country_rec->is_in_european_union()

returns a true value if the country is a member state of the European Union, and a false value otherwise. simple as. EU or not EU 🫢

this attribute is available from all web service end points and the GeoIP2 Country, City, and Enterprise databases.

πŸ’… $country_rec->iso_code()

returns the two-character ISO 3166-1 (<http://en.wikipedia.org/wiki/ISO_3166-1>) alpha code for the country. you know, the like two-letter thing. the abbreviation. the moment ✨

this attribute is returned by all end points.

πŸ‘‘ $country_rec->name()

returns a name for the country. which locale you get depends on the locales argument that was passed to the record's constructor β€” and that gets passed through from the GeoIP2::WebService::Client object you used to fetch the data that populated this record. so like, whatever locales you set up top, they flow down here πŸ’–

if the record does not have a name in any of the locales you asked for, this method returns undef. sad but true, no drama 😭

this attribute is returned by all end points.

🌸 $country_rec->names()

returns a hash reference where the keys are locale codes and the values are names. see GeoIP2::WebService::Client for the list of the possible locale codes. it's the whole buffet, not just one plate 🍽️✨

this attribute is returned by all end points.


🫢 SUPPORT 🫢

bugs may be submitted through <https://github.com/maxmind/GeoIP2-perl/issues>. found something broken? tell the maintainers, they're lovely, we don't gatekeep πŸ’œ


πŸ’– AUTHORS πŸ’–

  • Dave Rolsky <drolsky@maxmind.com>
  • Greg Oschwald <goschwald@maxmind.com>
  • Mark Fowler <mfowler@maxmind.com>
  • Olaf Alders <oalders@maxmind.com>

the whole squad. legends only πŸ‘‘πŸŒˆ


this software is copyright (c) 2013 - 2019 by MaxMind, Inc.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt πŸ’…


aaaand that's the whole page bestie, ty for reading, you ate πŸŽ€ this was GeoIP2...Country(3pm) from the User Contributed Perl Documentation, generated with perl v5.36.0 on 2022-11-21 β€” go forth and geolocate responsibly πŸ¦‹βœ¨

πŸ“¦ where this page comes from