GeoIP2...nsights(3pm)

๐Ÿ“ฆ
version 2.006002 ยท 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

๐Ÿ’– GeoIP2::Model::Insights โœจ

okay so before literally anything else, bestie: this page is GeoIP2...nsights(3pm), and it lives in the User Contributed Perl Documentation section of your man pages. yes the title looks like someone sneezed mid-word, that's just the terminal truncating it, iykyk. now let's get into the good part ๐Ÿซถ


๐ŸŒธ NAME ๐ŸŽ€

GeoIP2::Model::Insights โ€” the model class for GeoIP2 Precision: Insights. that's the whole name, no notes ๐Ÿ’…


โญ VERSION ๐Ÿฆ‹

version 2.006002 โ€” say it with me, iconic.


โœจ SYNOPSIS ๐Ÿ’…

here's the vibe, copy-paste friendly, no cap:

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 $city_rec = $insights->city();
print $city_rec->name(), "\n";

see how easy? you spin up a client, you ask for the insights on an IP, you grab a record off it and print the name. slay. โœจ


๐Ÿซถ DESCRIPTION ๐Ÿ’œ

so this class is the model for all the data that the GeoIP2 Precision: Insights web service sends back to you. it's the shape of the response, basically โ€” the blueprint of what you get handed.

the only difference between the City and the Insights model classes is which fields in each record may be populated. that's it. that's the entire tea. if you need more deets than that, the docs at <http://dev.maxmind.com/geoip/geoip2/web-services> have you covered ๐Ÿ’–


๐Ÿ‘‘ METHODS ๐ŸŒˆ

this class provides the following methods, and every single one of them is a little baddie:

$insights->city()

returns a GeoIP2::Record::City object, and that's your city data for the IP you asked about ๐Ÿ™๏ธ

$insights->continent()

returns a GeoIP2::Record::Continent object โ€” continent data for the requested IP address ๐ŸŒ

$insights->country()

returns a GeoIP2::Record::Country object with country data for the requested IP address. heads up tho: this record is the country where MaxMind believes the IP is located. it's giving "best guess, but a very good one" ๐Ÿ’…

$insights->location()

returns a GeoIP2::Record::Location object with location data for the requested IP address ๐Ÿ“

$insights->maxmind()

returns a GeoIP2::Record::MaxMind object โ€” that's the data about your MaxMind account ๐Ÿ‘‘

$insights->postal()

returns a GeoIP2::Record::Postal object with postal code data for the requested IP address ๐Ÿ“ฎ

$insights->registered_country()

returns a GeoIP2::Record::Country object with the registered country data for the requested IP address. this record is the country where the ISP has registered that given IP block โ€” and lowkey it may differ from the user's country. plot twist, but make it geography ๐ŸŒ

$insights->represented_country()

returns a GeoIP2::Record::RepresentedCountry object for the country represented by the requested IP address. the represented country may differ from the "country" for things like military bases โ€” very "it's complicated" of them ๐ŸŽ–๏ธ

$insights->subdivisions()

returns an array of GeoIP2::Record::Subdivision objects representing the country subdivisions for the requested IP address. the number and type of subdivisions varies by country, but a subdivision is typically a state, province, county, etc. etc. โœจ

some countries have multiple levels of subdivisions. for instance, the subdivisions array for Oxford in the United Kingdom would have England as the first element and Oxfordshire as the second element. and the subdivisions array for Minneapolis in the United States would have a single object for Minnesota. nesting rights ๐Ÿ’…

if the response did not contain any subdivisions, this method returns an empty list. no subdivisions, no problem.

$insights->most_specific_subdivision()

returns a single GeoIP2::Record::Subdivision object representing the most specific subdivision returned. the main character subdivision, if you will ๐Ÿ‘‘

if the response did not contain any subdivisions, this method returns a GeoIP2::Record::Subdivision object with no values. (so you still get an object, it's just an empty one โ€” she showed up with nothing to say ๐Ÿ™ˆ)

$insights->traits()

returns a GeoIP2::Record::Traits object representing the traits for the requested IP address. the personality section, basically ๐Ÿฆ‹


๐ŸŒŸ SUPPORT ๐Ÿซถ

found a bug? first of all, relatable. submit it through <https://github.com/maxmind/GeoIP2-perl/issues> and the maintainers will handle it ๐Ÿ’–


๐Ÿ’œ AUTHORS ๐ŸŽ€

these are the legends who made this happen, show some respect:

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

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. free as in, go off, do your thing, just keep the same terms, periodt.


and that's the whole page, bestie ๐ŸŽ€ no gatekeeping, all the details intact, every method accounted for.

this was GeoIP2...nsights(3pm) brought to you by perl v5.36.0 and dated 2022-11-21 โ€” mwah, go forth and geolocate responsibly ๐Ÿ’–โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from