Menu
GeoIP Legacy is available in a variety of downloadable databases. These databases use a custom binary format to maximize lookup speed. MaxMind also offers CSV versions of the same data. This is useful if you would like to import this data into a SQL RDBMS, for.
Latest version
Released:
MaxMind GeoIP2 API
Project descriptionDescription
This package provides an API for the GeoIP2 web services and databases. The API also works withMaxMind’s free GeoLite2 databases.
Installation
To install the geoip2 module, type:
If you are not able to use pip, you may also use easy_install from thesource directory:
Database Reader Extension
If you wish to use the C extension for the database reader, you must firstinstall the libmaxminddb C API.Please see the instructions distributed with it.
IP Geolocation Usage
IP geolocation is inherently imprecise. Locations are often near the center ofthe population. Any location provided by a GeoIP2 database or web serviceshould not be used to identify a particular address or household.
Usage
To use this API, you first create either a web service object with yourMaxMind account_id and license_key or a database reader object with thepath to your database file. After doing this, you may call the methodcorresponding to request type (e.g., city or country), passing it theIP address you want to look up.
If the request succeeds, the method call will return a model class for theend point you called. This model in turn contains multiple record classes,each of which represents part of the data returned by the web service.
If the request fails, the client class throws an exception.
Web Service Client Exceptions
For details on the possible errors returned by the web service itself, seehttp://dev.maxmind.com/geoip/geoip2/web-services for the GeoIP2 Precision webservice docs.
If the web service returns an explicit error document, this is thrown as aAddressNotFoundError, AuthenticationError, InvalidRequestError, orOutOfQueriesError as appropriate. These all subclass GeoIP2Error.
If some other sort of error occurs, this is thrown as an HTTPError. Thisis thrown when some sort of unanticipated error occurs, such as the webservice returning a 500 or an invalid error document. If the web servicereturns any status code besides 200, 4xx, or 5xx, this also becomes anHTTPError.
Finally, if the web service returns a 200 but the body is invalid, the clientthrows a GeoIP2Error.
Database ExampleAnonymous IP DatabaseConnection-Type DatabaseEnterprise DatabaseDatabase Reader Exceptions
If the database file does not exist or is not readable, the constructor willraise a FileNotFoundError on Python 3 or an IOError on Python 2.If the IP address passed to a method is invalid, a ValueError will beraised. If the file is invalid or there is a bug in the reader, amaxminddb.InvalidDatabaseError will be raised with a description of theproblem. If an IP address is not in the database, a AddressNotFoundErrorwill be raised.
Values to use for Database or Dictionary Keys
We strongly discourage you from using a value from any ``names`` property asa key in a database or dictionaries.
These names may change between releases. Instead we recommend using one of thefollowing:
What data is returned?
While many of the models contain the same basic records, the attributes whichcan be populated vary between web service end points or databases. Inaddition, while a model may offer a particular piece of data, MaxMind does notalways have every piece of data for any given IP address.
Because of these factors, it is possible for any request to return a recordwhere some or all of the attributes are unpopulated.
The only piece of data which is always returned is the ip_addressattribute in the geoip2.records.Traits record.
Integration with GeoNames
GeoNames offers web services and downloadabledatabases with data on geographical features around the world, includingpopulated places. They offer both free and paid premium data. Each feature isuniquely identified by a geoname_id, which is an integer.
Many of the records returned by the GeoIP web services and databases include ageoname_id field. This is the ID of a geographical feature (city, region,country, etc.) in the GeoNames database.
Some of the data that MaxMind provides is also sourced from GeoNames. Wesource things like place names, ISO codes, and other similar data from theGeoNames premium data set.
Reporting Data Problems
If the problem you find is that an IP address is incorrectly mapped, pleasesubmit your correction to MaxMind.
If you find some other sort of mistake, like an incorrect spelling, pleasecheck the GeoNames site first. Once you’vesearched for a place and found it on the GeoNames map view, there are anumber of links you can use to correct data (“move”, “edit”, “alternatenames”, etc.). Once the correction is part of the GeoNames data set, itwill be automatically incorporated into future MaxMind releases.
If you are a paying MaxMind customer and you’re not sure where to submit acorrection, please contact MaxMind support for help.
Requirements
This code requires Python 2.7+ or 3.5+. Older versions are not supported.This library has been tested with CPython and PyPy.
The Requests HTTP library is also required. See<http://python-requests.org> for details.
Versioning
The GeoIP2 Python API uses Semantic Versioning.
Support
Please report all issues with this code using the GitHub issue tracker
If you are having an issue with a MaxMind service that is not specific to theclient API, please contact MaxMind support for assistance.
Release historyRelease notifications
3.0.0
2.9.0
2.8.0
2.7.0
2.6.0
2.5.0
2.4.2
2.4.1
2.4.0
2.3.0
2.2.0
2.1.0
2.0.2
2.0.1
2.0.0
0.7.0
0.6.0
0.5.1
0.5.0
0.4.2
0.4.1
0.4.0
0.3.1
0.3.0
0.2.2
0.2.1
0.2.0
0.1.1
0.1.0
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for geoip2-3.0.0-py2.py3-none-any.whl
Hashes for geoip2-3.0.0.tar.gz
Maxmind GeoIP is a module that will perform geo-location lookups of a visitor's Ip address using the Maxmind GeoLite2 City database or the Maxmind GeoIP City/Isp/Org Web Service.
This module requires explicit activation in order to include geolocation data in tracking requests.
Installation
Note: if you already have this particular Maxmind database installed on your server, you may specify an alternate path for OWA to use by setting the
OWA_MAXMIND_DATA_DIR constant in your owa-config.php. For example:
define( 'OWA_MAXMIND_DATA_DIR', '/path/to/maxmind/data/dir/');
Maxmind GeoIP City/Isp/Org Web Service
The module may also be configured to use the Maxmind City/Isp/Org Web Service instead of a local database. To use this web service you must first purchase a web service license key from Maxmind at http://www.maxmind.com/app/web_services.
Once you have obtained a key, you will need to set two settings by adding the following to your owa-config.php configuration file:
$this->set('maxmind_geoip', 'lookup_method', 'geoip_city_isp_org_web_service'); $this->set('maxmind_geoip', 'ws_license_key', 'YOUR_LICENSE_KEY');
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |