GeoIP2...::City(3pm)
β¨ NAME β¨
GeoIP2::Record::City β it's the lil record that holds all the city data for an IP address π
(it lives in the User Contributed Perl Documentation, so you already know it's a perl thing, bestie πͺ)
πΈ VERSION πΈ
version 2.006002 β that's the one, no cap π
π¦ SYNOPSIS π¦
okay so here's the whole vibe, in code:
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";
likeβ¦ you spin up a client, you ask for insights on an IP, you grab the city record, you print the name. slay. that's it, that's the whole flow π
π DESCRIPTION π
This class contains the city-level data associated with an IP address. literally what it says on the tin π
This record is returned by all the end points except the Country end point. so likeβ¦ every end point shows up to the party except Country. Country said no. π
π METHODS π
This class provides the following methods:
β $city_rec->confidence()
This returns a value from 0-100 indicating MaxMind's confidence that the city is correct. it's giving "how sure are we, on a scale of zero to a hundred" energy π₯
This attribute is only available from the Insights end point and the GeoIP2 Enterprise database. so if you're not on those, don't come looking for it, bestie π
β $city_rec->geoname_id()
This returns a "geoname_id" for the city. it's the city's lil ID number, iykyk πͺͺ
This attribute is returned by all end points. every single one. periodt π
β $city_rec->name()
This returns a name for the city. The locale chosen depends on the "locales" argument that was passed to the record's constructor. This will be passed through from the GeoIP2::WebService::Client object you used to fetch the data that populated this record. so basically the client picks the locale and the record just inherits the vibe β¨
If the record does not have a name in any of the locales you asked for, this method returns "undef". yeah. undef. it happens. don't take it personally π«Ά
This attribute is returned by all end points. all of them, always π―
β $city_rec->names()
This returns a hash reference where the keys are locale codes and the values are names. See GeoIP2::WebService::Client for a list of the possible locale codes. so like, every translation of the city name, all in one hash. iconic π
This attribute is returned by all end points. yes queen, all of them π
π«Ά SUPPORT π«Ά
Bugs may be submitted through <https://github.com/maxmind/GeoIP2-perl/issues>.
(pls be nice when you file one, the maintainers are people too π)
π§ AUTHORS π§
- Dave Rolsky
<drolsky@maxmind.com> - Greg Oschwald
<goschwald@maxmind.com> - Mark Fowler
<mfowler@maxmind.com> - Olaf Alders
<oalders@maxmind.com>
four absolute legends, we stan π
π COPYRIGHT AND LICENSE π
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.
fr fr, that's the whole page. nothing skipped, nothing invented. go forth and look up some cities π
k bye bestie, this was perl v5.36.0, dated 2022-11-21, and you just read GeoIP2::Record::City π¦β¨
π¦ where this page comes from
- debian bookworm: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgeoip2-perl 2.006002-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms