skillfed

ip3country

A zero-dependency, local, fast, tiny ip-address to country lookup

ip3country v0.4.0 8.6M downloads/30d#1,602 on PyPI4
Permissive license ISC Active released

What it is and what it does

ip3country is a minimal IP-to-country lookup library designed for speed and size. It maps IP addresses to their ISO 3166-1 alpha-2 country codes using a compacted database derived from IP2Location LITE data, all in under 500KB with zero external dependencies. The library supports both string and numeric IP address formats and is built for applications that need fast, local country detection without the overhead of larger geolocation libraries.

The package is actively maintained and ranks in the top 5000 PyPI packages by download volume. It was created at Statsig to power country-level feature flag rollouts and A/B tests, making it suitable for any application requiring lightweight, offline country-level IP geolocation without network calls or large data files.

Use it for:

  • Evaluate location-based feature flags or A/B test conditions based on user IP country.
  • Filter or route traffic by country in a lightweight, self-contained service.
  • Add country-level analytics or logging to requests without external API calls.
  • Implement country-based access controls or compliance checks in edge functions.
  • Populate country metadata in high-volume logging pipelines where size and speed matter.

Worth the install?

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

Looks up the ISO 3166-1 alpha-2 country code for an IP address using a compacted local database, with zero runtime dependencies and a footprint under 500KB.

Yes. Zero dependencies, active maintenance, permissive license, and a proven track record of high download volume make this a reliable choice for any application needing fast, local IP-to-country lookup. The small footprint and offline operation are significant advantages over larger geolocation libraries. Verify that IP2Location LITE's accuracy meets your geographic coverage needs before deploying.

Install

ip3country on PyPI

pip

pip install ip3country

uv

uv add ip3country

poetry

poetry add ip3country

Installing ip3country

Before you install

Installs cleanly with no runtime dependencies. Actively maintained with a recent commit on 2026-08-12 and steady releases since first_release 2021-10-04.

License in practice

Licensed under ISC (permissive), allowing commercial and private use with minimal restrictions. Attribution to IP2Location LITE data is required per the CCA license of the underlying database.

Quickstart

pip install ip3country

from ip3country import CountryLookup

lookup = CountryLookup()
print(lookup.lookupStr("123.45.67.8"))  # 'KR'

Verify before relying

  • Whether accuracy for country-level lookups meets your specific use case (IP2Location LITE accuracy varies by region and IP type).
  • Whether the compacted database is updated regularly and how to refresh it if needed.

Package facts

License ISC (permissive)
Python support supports the current Python release (>=2.0)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 400 days since the last release
Last repo commit
First released
Downloads 8,613,615/month — #1,602 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: ip3country-0.4.0-py3-none-any.whl

Keywords: ip, country, lookup, statsig

Intended Audience :: DevelopersProgramming Language :: PythonProgramming Language :: Python :: 3Topic :: Software Development :: Libraries

Tags

ip address to country code lookupgeoip country detectionlightweight ip geolocationlocal ip country mappingfast country code from ipoffline ip geolocationminimal ip2country library
geolocationip-lookuplightweight

More Libraries packages