Skip to main content

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

Project description

iptocc

Fast, offline IPv4/IPv6 to ISO 3166-1 alpha-2 country code lookup for Python.

[!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 ~100 ns, and a batch API was added. IPv6 is still supported.

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 alongside the library
  • Database 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

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.2.1.tar.gz (852.3 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.2.1-cp310-abi3-win_amd64.whl (931.1 kB view details)

Uploaded CPython 3.10+Windows x86-64

iptocc-3.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

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

iptocc-3.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

iptocc-3.2.1-cp310-abi3-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.2.1-cp310-abi3-macosx_10_12_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for iptocc-3.2.1.tar.gz
Algorithm Hash digest
SHA256 36fba8d440307c7ecc63feb0054e1c678b042b242f99c06b316b285393c35448
MD5 9f3e5d02469d1552780d872d4ccf9345
BLAKE2b-256 f5ad2df6cd4008a8aacdd9316a6421c227207040efa292b159fa3a1153a63223

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: iptocc-3.2.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 931.1 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.2.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0b1e074b6422973a1a27cc176f4142bc1193edfff057da37bf003bb0eae71c35
MD5 2e197363652b8dfa339a6d0d0c40a3a2
BLAKE2b-256 fd05378a2c6c9f9a6268a53b1eecbbb8330c929ee5164c6f29fe24c41a358f18

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 17751011e96d8e763d8d028a621b787e91f97e321e49f5702ae594fd54a28ed4
MD5 8faa1e677708ecb885f82a1ecd49e4a9
BLAKE2b-256 70cb1ffcecabaaeb36eada0219acca0784901b2303c3178a8b64a72d4f9b0c46

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f081f4d743139894c3be7a131ad8295bc964db0bbff0678bab4d4ea7b4aeadea
MD5 f1f306f850902e0f1b53e09e673efebc
BLAKE2b-256 16dfd17915808a1a770dbe0b32a269e0fafe04def19ed8234054753f53ed4afc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1db7f0b4622e68f0f0da44cb7c14f865db909a1c9df200a5d962c21f42479478
MD5 91b8f2d9e7eccbb2f909a1a799899cab
BLAKE2b-256 70bff05f03c5448b47d99a9a1df73c47a60828ddf04e1dd6380cc6d253d8eeac

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 61dfb79a9e45b810114400050f9478f5c8a0cc4a6dfae95c4f8434ac53526b71
MD5 10d9b163f0df988222e4874d15dd9af7
BLAKE2b-256 169da3c133a0f1c4f9d927c15ee71c884cd9c9a32b10e9f64b9c530d49288302

See more details on using hashes here.

Provenance

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