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.2.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.2-py3-none-any.whl (1.5 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ip_to_country-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 98d99ce338958583506b7b446c64f47a98acfe0c9fcdf419cd7429a8c5213b4b
MD5 ec772669770d0d5c9a18d738e2a48b07
BLAKE2b-256 f2881328ec54e0012707cd25c66147bb9435e0479dce9c8dff4f3fa25147dd64

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ip_to_country-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e9ed48466bab9037ef86b20107c4770dc3f5893591c9684a4b252bbdb0629f0f
MD5 c0377393f87cb4a019b1bde5b10da1cf
BLAKE2b-256 9ee4441857e7ea34f7cffde3ebe82f1d0ca55cea67366493853b9d26d4b48e95

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