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.67.tar.gz (445.8 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.67-cp310-abi3-win_amd64.whl (514.7 kB view details)

Uploaded CPython 3.10+Windows x86-64

iptocc-3.3.67-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (626.6 kB view details)

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

iptocc-3.3.67-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (626.6 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

iptocc-3.3.67-cp310-abi3-macosx_11_0_arm64.whl (623.0 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.3.67-cp310-abi3-macosx_10_12_x86_64.whl (615.4 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: iptocc-3.3.67.tar.gz
  • Upload date:
  • Size: 445.8 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.67.tar.gz
Algorithm Hash digest
SHA256 4f007aad4d3f1bb116588c47f288fdd561678e807eff58c6ef9ec9036070bf6f
MD5 80e29f37df87d741a908b36bc8871f31
BLAKE2b-256 006e6285f8f5c37c0ee871872af62ed6e5b98d9b70f425ab0830ef2986eabdd7

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: iptocc-3.3.67-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 514.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.67-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 dd072a72ce67054819eea821a14eb2e04b2cb3b78b625c393dd9585167ed72a6
MD5 825044680fa80598e837d0768d660b60
BLAKE2b-256 380354a18449bc91c345e7a12ec5ca47be03df5c9cd82834bad7285d934033dd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.67-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ac508176e4eb0b08088706535f3a4cf655c256775600311148db9f9372fc2db5
MD5 425f56a60778859be89b52939b7b1090
BLAKE2b-256 46ae52f8cbeb4f3a0da5462b1e5b26940efa1a30e55a41aebe8e2cb65c7ab0f1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.67-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 709d37004e2d948ca68278648933d3357faa9333f69bc27e2ba0a78010af08ba
MD5 47cbea4c0f925a3222437b38a06e37d1
BLAKE2b-256 2c63e8fd52f7290cc16c383cc1012455c6d9c8580e34e812745fc4befd20fcb1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.67-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d06788422ecc057a42c1bd60d4300a3359447286fa8a9e5a56a4a166b53c7851
MD5 02a271642c12325dabb7735e9b0afd4a
BLAKE2b-256 cc84196ee406faa9e060630008460809d3fb6fe9acf792f9687b7799e68029ad

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.67-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4e4d87898ef698bf4c23bd023b11ae0f37a3b871ed95634cb4158efddfef8f4a
MD5 ad38c4d5ed8632caf97fb9d5bc7bc483
BLAKE2b-256 dbc054d35ba33866b3010887ff93d415d493ea1baaa8897f308030e17cd5c371

See more details on using hashes here.

Provenance

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