Skip to main content

Convert IP addresses to countries using delegated registry data

Project description

ip-to-country

ip-to-country is a blazing-fast, offline Python library that determines the country for any given IP address (IPv4 or IPv6) using pre-parsed regional internet registry data.

No internet access or third-party APIs required: everything runs locally and instantly.


⚡ Features

  • 🌍 Offline IP Geolocation – no network calls or external services
  • Super Fast Lookup – optimized with binary search for IPv4
  • Supports IPv4 and IPv6
  • 📦 Uses Official RIR Data – from AFRINIC, RIPE, ARIN, APNIC, and LACNIC
  • 🌐 Country Code + Name Output – based on ISO 3166
  • 🕵️ Supports special codes like A1 (Anonymous Proxy), A2, O1, etc.

📦 Installation

pip install ip-to-country

🛠️ Usage

from ip_to_country import IpToCountry

ip_lookup = IpToCountry()
country_info = ip_lookup.ip_to_country("8.8.8.8")

print(country_info)

# Output: {'country_code': 'US', 'ISO3166-1-Alpha-3': 'USA', 'region': 'Americas', 'continent': 'NA', 'languages': ['en-US', 'es-US', 'haw', 'fr'], 'country_name': 'United States of America', 'currency': 'US Dollar', 'currency_code': 'USD'}

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

ip_to_country-1.0.0.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ip_to_country-1.0.0-py3-none-any.whl (1.5 MB view details)

Uploaded Python 3

File details

Details for the file ip_to_country-1.0.0.tar.gz.

File metadata

  • Download URL: ip_to_country-1.0.0.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ip_to_country-1.0.0.tar.gz
Algorithm Hash digest
SHA256 02ddc543591fa7bec07858882643c3f0b8d21ffe52b26e2913d9dd1c70233b86
MD5 cca6d2cacfed5c2d0f31ca871bcd7147
BLAKE2b-256 56835e8667cbe9bd88fb0bf0634cda1dd41bdda2ef9d58495b2afeab3956fbce

See more details on using hashes here.

File details

Details for the file ip_to_country-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ip_to_country-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ip_to_country-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a9487bd0a481aca1c38f100eb2a90d399d21527b2cc152c067cca03d7bb368a
MD5 3ea5324f2af8cd9231facd8e29561288
BLAKE2b-256 ac7f2303b52fdf1e94c9ec64fb91fb6b26fffb59f803b07d7d99cf6a96fcb855

See more details on using hashes here.

Supported by

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