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.1.tar.gz (3.5 kB 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.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ip_to_country-1.0.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • 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.1.tar.gz
Algorithm Hash digest
SHA256 377cce418a368c82317f4dd9769095dfd17131bf86f940f0ce2e29a7793ed569
MD5 1b0f8d519785a0af4b89e7ae75ec760b
BLAKE2b-256 cdcca1dd52b7f912545f2a8713c598dd1bc6b8f2800e4bf7675d0f0c467c3e9c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ip_to_country-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1134e69bb99339529eee2e9fea1eb7bd465e5cf62c5d1a39c40591213582965b
MD5 f3f3f6d44e46642513b8cade2a11defc
BLAKE2b-256 ebc22a7e19caae8a78f4f6fc95f48e2dfb968081c68fd6a23ba801d41059a936

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