skillfed

geoip2

MaxMind GeoIP API

geoip2 v5.3.0 18.0M downloads/30d#1,089 on PyPI1,216
Permissive license Apache-2.0 Active released

What it is and what it does

geoip2 is the official Python client library for MaxMind's GeoIP and GeoLite services. It provides both synchronous and asynchronous interfaces to query IP geolocation data from MaxMind's web services or from local MaxMind database files. The library handles authentication, request formatting, error handling, and response parsing, returning structured objects with country codes, city names, subdivisions, postal codes, latitude/longitude, and network information.

The package is designed for developers who need to determine the geographic location or network details of an IP address in their application. It supports both real-time web service queries (with optional Sandbox or GeoLite endpoints) and offline database lookups using local .mmdb files. The library abstracts away HTTP communication (via requests or aiohttp) and binary database parsing (via maxminddb), making it straightforward to integrate IP geolocation into web services, analytics pipelines, or security workflows.

Use it for:

  • Determine user location for content localization or regional compliance in web applications.
  • Detect suspicious login attempts by comparing user IP location against historical patterns.
  • Analyze traffic sources and geographic distribution of website visitors.
  • Implement geo-blocking or geo-routing logic based on IP address origin.
  • Enrich server logs or analytics data with geographic and network metadata.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Queries MaxMind's GeoIP web services and databases to look up geographic and network information for IP addresses, returning country, city, subdivision, postal, and location data.

Yes. geoip2 is the official, actively maintained client for MaxMind's geolocation services, with low install friction, permissive licensing, no known vulnerabilities, and broad Python version support. Install it if you need to look up IP geolocation data; it is the standard choice for this task. Verify you have a MaxMind account and license key (or a local database file) before relying on it in production.

Install

geoip2 on PyPI

pip

pip install geoip2

uv

uv add geoip2

poetry

poetry add geoip2

Installing geoip2

Before you install

Low install friction; pure Python wheel with three runtime dependencies (aiohttp, maxminddb, requests). Actively maintained with a release 29 days ago and last commit on 2026-08-10. Supports modern Python versions (3.10–3.14).

License in practice

Licensed under Apache-2.0 (permissive). You may use, modify, and distribute this package freely in commercial or private projects, provided you include a copy of the license and state any material changes.

Quickstart

import geoip2.webservice

with geoip2.webservice.Client(account_id, 'license_key') as client:
    response = client.city('203.0.113.0')
    print(response.country.iso_code)  # 'US'
    print(response.city.name)  # 'Minneapolis'

Requires a MaxMind account ID and license key for web service use, or a local GeoIP/GeoLite database file for database reader mode. Optional C extension for database reader requires libmaxminddb system library.

Verify before relying

  • Whether the C extension for database reader significantly improves performance over pure Python mode.
  • Accuracy and freshness guarantees for GeoIP data returned by the web service or databases.

Package facts

License Apache-2.0 (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 3 — aiohttp, maxminddb, requests
Maintenance actively maintained — 29 days since the last release
Last repo commit
First released
Downloads 18,029,953/month — #1,089 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: geoip2-5.3.0-py3-none-any.whl

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentIntended Audience :: DevelopersIntended Audience :: System AdministratorsProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: InternetTopic :: Internet :: Proxy Servers

Tags

ip geolocation lookupgeoip database readermaxmind api clientip to city countrygeographic ip addressgeolite web serviceip location data
geolocationip-lookupmaxmind

More Internet packages