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


Release history Release notifications | RSS feed

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.83.tar.gz (446.0 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.83-cp310-abi3-win_amd64.whl (515.7 kB view details)

Uploaded CPython 3.10+Windows x86-64

iptocc-3.3.83-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (628.6 kB view details)

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

iptocc-3.3.83-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (627.4 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

iptocc-3.3.83-cp310-abi3-macosx_11_0_arm64.whl (619.0 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.3.83-cp310-abi3-macosx_10_12_x86_64.whl (618.3 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: iptocc-3.3.83.tar.gz
  • Upload date:
  • Size: 446.0 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.83.tar.gz
Algorithm Hash digest
SHA256 2362cfc06f20ce32c704b263751a98f7573a6f8608216b6c10be1c3217c051a9
MD5 3ff327100d0928612a793657c8d8cedb
BLAKE2b-256 30b8244b5154fe92941ee480fcac086ca2007f52d05bb78ee3fca2ac5d393455

See more details on using hashes here.

Provenance

The following attestation bundles were made for iptocc-3.3.83.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.83-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: iptocc-3.3.83-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 515.7 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.83-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1abfaae8d2a00b4cd2c72897a0e00db63f9e8789ce4316df6f4ea32e91920c41
MD5 fb38b5fb2a5db1f57cf13ee2df0a04f6
BLAKE2b-256 03ad7b65eccbe6bccb73f9be131ec25d28c047d1e9a302e40351bce3e6c90105

See more details on using hashes here.

Provenance

The following attestation bundles were made for iptocc-3.3.83-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.83-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for iptocc-3.3.83-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6f7aa323d15cdc91179055b38ad97613ed2397068f0f7e05d56fcc9278b52879
MD5 543d0e32a47590dc6060a37a3b729078
BLAKE2b-256 491aaa7f256be5f1b4dcf68d005897f7fac8924fe8dfaf8df95070ae823bc534

See more details on using hashes here.

Provenance

The following attestation bundles were made for iptocc-3.3.83-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.83-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for iptocc-3.3.83-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 19620553ab032db35e5b86599a332fadd2104840daad979c3fbf2cf1490c1191
MD5 712d4c34cd57ba5fc0c0cb1a551377e4
BLAKE2b-256 123a5126ae5c59d105d5149c5a8b2114121e6672250c55cb00095f711cf11f85

See more details on using hashes here.

Provenance

The following attestation bundles were made for iptocc-3.3.83-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.83-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for iptocc-3.3.83-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c9950dd1148b4a63c17e0e58a5ca6075708503b4f59dcaa7ecdef1b23fd6b32
MD5 68e77d87cdfab0701bd674f12e0314b1
BLAKE2b-256 f65fcbb3e8c2fd02b50e03d139715f3fa47c9a453db52a69abac08c4ddaf0177

See more details on using hashes here.

Provenance

The following attestation bundles were made for iptocc-3.3.83-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.83-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for iptocc-3.3.83-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0663cb95bb88327ec1517ae098ee8d098ce9c9a8529eec32e5b337b512ae4050
MD5 1f9d7a32e4c6d1e563b7f06cc38dff36
BLAKE2b-256 5be102de68c7690ec4f18d3beab2f474924aed96717140ccbb427ea8fbb96e44

See more details on using hashes here.

Provenance

The following attestation bundles were made for iptocc-3.3.83-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