skillfed

geoip2fast

GeoIP2Fast is the fastest GeoIP2 country/city/asn lookup library that supports IPv4 and IPv6. A search takes less than 0.00003 seconds. It has its own data file updated twice a week with Maxmind-Geolite2-CSV, supports IPv4/IPv6 and is Pure Python!

geoip2fast v1.2.2 214.7K downloads/30d#9,410 on PyPI91
Permissive license MIT Active released

What it is and what it does

GeoIP2Fast is a pure-Python geolocation library that maps IP addresses to geographic and network information using local binary data files. It loads Maxmind GeoLite2 data into memory and performs lookups via binary search on ordered IP ranges, returning country codes, city names, ASN names, and CIDR blocks for both IPv4 and IPv6 addresses. The library requires no external dependencies or network calls—only the Python file and a .dat.gz data file.

The package ships with a small country-level IPv4 database, but city and IPv6 variants must be downloaded separately or generated from Maxmind CSV files using the included geoip2dat.py tool. Data files are updated twice weekly. The library supports Python 3.7 through 3.13 and PyPy3, runs on Linux, Windows, and macOS, and is designed for applications that need fast, offline geolocation without external service dependencies.

Use it for:

  • Geoblock or route traffic based on IP country origin in web applications or APIs.
  • Enrich server logs or analytics with geolocation data without making external API calls.
  • Identify ASN and network ownership for security monitoring or abuse detection.
  • Resolve city-level location for user analytics or localization features in high-throughput services.
  • Generate test data using the random IP address generation functions for unit or integration tests.

Worth the install?

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

GeoIP2Fast performs fast geolocation lookups for IPv4 and IPv6 addresses, returning country codes, city names, ASN information, and CIDR blocks from a local binary data file.

Yes, with conditions. Install if you need fast, offline IP geolocation and are willing to manage data file downloads separately. The library is actively maintained, has no dependencies, and supports current Python versions. High install friction (separate data file requirement) and the need to choose between country/city and IPv4/IPv6 variants make it less suitable for quick prototyping, but it is well-suited for production systems where speed and offline operation matter.

Install

geoip2fast on PyPI

pip

pip install geoip2fast

uv

uv add geoip2fast

poetry

poetry add geoip2fast

Installing geoip2fast

Before you install

Installation friction is high because the package requires a separate binary data file (.dat.gz) to function; the pip package includes only country-level IPv4 data, and city or IPv6variants must be downloaded separately or generated manually. The library itself has no runtime dependencies and is actively maintained.

License in practice

MIT license is permissive; you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.

Quickstart

pip install geoip2fast

from geoip2fast import GeoIP2Fast
geo = GeoIP2Fast()
result = geo.lookup('8.8.8.8')
print(result)

A .dat.gz data file must be present in the library directory or application directory; the default geoip2fast.dat.gz (country IPv4 only) is included, but city or IPv6 databases require separate download.

Verify before relying

  • Whether the lookup speed claim of 'less than 0.00003 seconds' is measured under realistic application conditions or in controlled benchmarks.
  • Compatibility and performance behavior under PyPy3 compared to CPython across different data file sizes.
  • Whether the reduced versions (geoip2fastmin.py, geoip2fastminified.py) are production-ready or still in testing.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.7)
Install friction high — source build required
Runtime dependencies none
Maintenance actively maintained — 784 days since the last release
Last repo commit
First released
Downloads 214,693/month — #9,410 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: geoip2fast-1.2.2.tar.gz

Keywords: geoip, geoip2, geolite2, maxmind, geoip2fast, geolocation, geolocalization, geo ip, ipaddress, ip, geo, ipv4, ipv6, pure-python, purepython, pure python, geoiptofast, geoiptoofast, geoip2dat, mmdb, tools

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseOperating System :: MacOSOperating System :: Microsoft :: Windows :: Windows 10Operating System :: Microsoft :: Windows :: Windows 11Operating System :: POSIXOperating System :: POSIX :: BSDOperating System :: POSIX :: BSD :: FreeBSDOperating System :: POSIX :: LinuxOperating System :: UnixProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: PyPyTopic :: InternetTopic :: Internet :: FingerTopic :: Scientific/EngineeringTopic :: SecurityTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: LocalizationTopic :: System :: MonitoringTopic :: System :: NetworkingTopic :: System :: Systems AdministrationTopic :: Utilities

Tags

geoip lookup libraryip geolocation ipv4 ipv6fast country city asn lookupmaxmind geolite2 local databasepure python geoipoffline ip location lookupasn country city resolver
geolocationoffline-lookuppure-python

More Libraries packages