ip3country
A zero-dependency, local, fast, tiny ip-address to country lookup
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 ip3countryuv
uv add ip3countrypoetry
poetry add ip3countryInstalling 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
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
IP2LocationLooks up geolocation data (country, region,…
permissive · top 15,000 on PyPI
pycountry-convertConverts between ISO country codes (alpha-2,…
permissive · top 15,000 on PyPI
geoip2fastGeoIP2Fast performs fast geolocation lookups…
permissive · top 15,000 on PyPI
iso3166Converts between ISO 3166-1 country codes…
permissive · top 5,000 on PyPI
maxminddb-geolite2Provides geolocation lookups by IP address…
unclear · top 15,000 on PyPI
geoip2Queries MaxMind's GeoIP web services and…
permissive · top 5,000 on PyPI
country_listProvides ISO 3166-1 country codes and names in…
permissive · top 15,000 on PyPI
ipinfoQueries the IPinfo.io API to retrieve…
permissive · top 15,000 on PyPI
pgeocodepgeocode queries postal codes to retrieve GPS…
permissive · top 5,000 on PyPI
pycountryProvides programmatic access to ISO standard…
copyleft · top 1,000 on PyPI