Skip to main content

Automatic updates and administration of MaxMind GeoIP2 databases.

Project description

Latest Travis CI build status Latest PyPI version Python versions Code Climate Test coverage Requirements Status

Automatic updates and administration of MaxMind GeoIP2 databases.

To install geoip2-tools, run this command in your terminal:

$ pip install geoip2-tools

This is the preferred method to install geoip2-tools, as it will always install the most recent stable release.


To use this library you must first obtain a license from Maxmind. It is free for the geolite2 version of the database.

  1. Sign up for a Maxmind Geolite2 account

  2. Log in to your Maxmind account

  3. In the menu on the left, navigate to Services > My License Key.

  4. Click Generate new license key.

  5. Save your license key in a secure site.

geoip2-tools downloads the latest version of the database and keeps it updated for you. By default every 7 days it is downloaded from the Maxmind servers.

from geoip2_tools.manager import Geoip2DataBaseManager

geoip2_manager = Geoip2DataBaseManager('<license key>')

print(geoip2_manager['country']'')  # Australia

Geoip2-tools has aliases for the city, country, and asn Geolite2 databases. The country database is smaller than city. The city database also contains the countries:

city = geoip2_manager['country']'<ip address>')

To obtain the ASN you must use the asn database:

asn = geoip2_manager['country'].reader.asn('<ip address>')

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geoip2-tools-0.1.1.tar.gz (17.2 kB view hashes)

Uploaded Source

Built Distribution

geoip2_tools-0.1.1-py2.py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page