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.3.tar.gz (852.4 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.3-cp310-abi3-win_amd64.whl (929.6 kB view details)

Uploaded CPython 3.10+Windows x86-64

iptocc-3.2.3-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.3-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.3-cp310-abi3-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.2.3-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.3.tar.gz.

File metadata

  • Download URL: iptocc-3.2.3.tar.gz
  • Upload date:
  • Size: 852.4 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.3.tar.gz
Algorithm Hash digest
SHA256 d32a4f232bc8d8e2da669d450571ee8c2748027336533a5d310b889987342f80
MD5 b1e811b270b641ab8ef0dc31da0d181e
BLAKE2b-256 9e81097421f3ed5610972141ac14336ef176b74be1e6e9f4c7469f3111241a90

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: iptocc-3.2.3-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 929.6 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.3-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1a67c2288173a989f086d8d2ce0374468beba8a60cd2449554558364e2b7ac5d
MD5 712c0a63e2875e10d9ac8fb845c28112
BLAKE2b-256 445b1424bd291d56884db9f3579f7a93fa8eb87523130e53c70f230ccd357afb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.3-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ddc3365ebccbdfe7ff489943d82bfba6b3bd0a57bee534dbe1a4e4df999c498a
MD5 9560ac671446e6a1730811a335ab798f
BLAKE2b-256 6aea15b6e8a3ff3ed7b5e218feff6884d13be3c278bcb109a72e80cb569f3c4b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.3-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 413aab73236bbc81e1528d74ae06e8e3571a5ecd7e2c0395be0c051a930e49ef
MD5 6841e205adc7fe72c1f9e07d7a5e575f
BLAKE2b-256 1ab99c7e8998456756ae982e4aea058e4cbe57e0200645ab12c958b85da270ec

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.3-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0543126072d1c2f43ce9e24e6792b20580b6d48521541138bd71a1bad5af716
MD5 71df118d7450dbc9b0247aba3b7060d5
BLAKE2b-256 43e5c44bec2924107d0b90fb300f3ed1723ec8cdfd80d63293cefc37d07938c7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.3-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 64d880d9343112084eb13dd9572c5d196ac77b1236130306f630fd5baf3cf8c9
MD5 0758c4beb6e37c873b7e41d6984744c5
BLAKE2b-256 ca67e419c8f0251d2cd698bc241e416af7f6f27a6b34737d0678c69a630b7b44

See more details on using hashes here.

Provenance

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