Skip to main content

Fast, offline IP-to-country lookup. Python bindings over the Rust iptocc crate.

Project description

iptocc

PyPI Python License

Python bindings for the iptocc Rust crate. Offline IPv4 and IPv6 to ISO 3166-1 alpha-2 country code lookup.

Note: Country codes reflect the country assigned by a Regional Internet Registry (RIR) to each IP block, not where the block is being used. RIR data agrees with MaxMind for ~95% of IPv4 addresses and has minimal discrepancies for IPv6 (Zander, 2012).

Important: iptocc 3.0 is a complete Rust rewrite. Versions 2.x and earlier were pure Python on top of pandas. The public API stays mostly compatible (see migration notes below), single-lookup latency dropped from ~78 ms to ~44-141 ns, and a batch API was added.

Features

  • Offline lookup, no API keys, no network calls
  • IPv4 and IPv6 in one call
  • Single string OR batch (any iterable of strings)
  • Lookup data embedded in the wheel; no runtime file I/O
  • iptocc CLI installed with pip install iptocc
  • Data refreshed nightly from the five Regional Internet Registries

Install

Requires Python 3.10 or newer.

pip install iptocc

Usage

from iptocc import country_code

country_code("8.8.8.8")                       # "US"
country_code(["8.8.8.8", "1.0.16.1"])         # ["US", "JP"]

A CLI is installed alongside the library:

$ iptocc 8.8.8.8 1.0.16.1
8.8.8.8 US
1.0.16.1 JP

Migrating from 2.x

# 2.x
from iptocc import get_country_code, CountryCodeNotFound
try:
    cc = get_country_code("8.8.8.8")
except CountryCodeNotFound:
    cc = None

# 3.x
from iptocc import country_code
cc = country_code("8.8.8.8")  # returns None on miss

See also

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

iptocc-3.3.24.tar.gz (444.9 kB view details)

Uploaded Source

Built Distributions

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

iptocc-3.3.24-cp310-abi3-win_amd64.whl (513.2 kB view details)

Uploaded CPython 3.10+Windows x86-64

iptocc-3.3.24-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (624.4 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

iptocc-3.3.24-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (624.8 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

iptocc-3.3.24-cp310-abi3-macosx_11_0_arm64.whl (620.7 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.3.24-cp310-abi3-macosx_10_12_x86_64.whl (614.9 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file iptocc-3.3.24.tar.gz.

File metadata

  • Download URL: iptocc-3.3.24.tar.gz
  • Upload date:
  • Size: 444.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for iptocc-3.3.24.tar.gz
Algorithm Hash digest
SHA256 c55fe0ee9861bd8c924651a0a948b8021484a58f9ebef3352cdea258084e7457
MD5 dd7d81ed205319ed10e3833a4720fae4
BLAKE2b-256 f49a2177dd97fac5ee5a052c943d8d5719b9c415997415bc32cbca34d56d5d00

See more details on using hashes here.

Provenance

The following attestation bundles were made for iptocc-3.3.24.tar.gz:

Publisher: publish-pypi.yml on roniemartinez/IPToCC

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file iptocc-3.3.24-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: iptocc-3.3.24-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 513.2 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for iptocc-3.3.24-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d1ffcc198999281dd2d3573d774aee260fb8df62facd85a9d124e626f977e9fc
MD5 72f21c5b2cf4127aab2c249dab5ad8ef
BLAKE2b-256 ce329dded381a7090b60fc1e84342842b1bcb7d7d0a880c1aa960fa80fa94fae

See more details on using hashes here.

Provenance

The following attestation bundles were made for iptocc-3.3.24-cp310-abi3-win_amd64.whl:

Publisher: publish-pypi.yml on roniemartinez/IPToCC

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file iptocc-3.3.24-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for iptocc-3.3.24-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2d7f5433f58214ea947158917acbc76a3fbb5c379f554b6069de219ad9d2c7e9
MD5 ca3e0ead8cf458fd1497353a51f538bd
BLAKE2b-256 e7e33f80026b4a96b1344e92eeeb494fe0678b3be5189ef3bbc73b67d2afc30c

See more details on using hashes here.

Provenance

The following attestation bundles were made for iptocc-3.3.24-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-pypi.yml on roniemartinez/IPToCC

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file iptocc-3.3.24-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for iptocc-3.3.24-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5ddaa4cb6eb200a95ad30da4c06e2549ec4e451d6d5294f9c5c9ea82f471f93b
MD5 5233b95767817ceb1d112d4c314c6d6b
BLAKE2b-256 20e67c76e04204731076066f52e0d193c5b1567d430b34b543cecc4a19db6d63

See more details on using hashes here.

Provenance

The following attestation bundles were made for iptocc-3.3.24-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-pypi.yml on roniemartinez/IPToCC

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file iptocc-3.3.24-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for iptocc-3.3.24-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d58ba7edbb0aecb8b6af5684925d7d8a397f4f956aff964c0590a1f206286ed0
MD5 50d11f1482c896f74a85860ad9482770
BLAKE2b-256 ea8f8d42518598bd456b193c674d31fa0ce956da3677d76b8c6f8de85491cc18

See more details on using hashes here.

Provenance

The following attestation bundles were made for iptocc-3.3.24-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: publish-pypi.yml on roniemartinez/IPToCC

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file iptocc-3.3.24-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for iptocc-3.3.24-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 aa4b138a8cbd69dba03aa3f19443f7b8d07a841a92eddc091c56df879036645d
MD5 d92b7fdc64c3274e60195eb5f9d3ef94
BLAKE2b-256 19e6b47555d12246edd2d7b833624b6c515f9c057d7435d937ae59e1eb182e1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for iptocc-3.3.24-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: publish-pypi.yml on roniemartinez/IPToCC

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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