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.36.tar.gz (445.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.36-cp310-abi3-win_amd64.whl (513.6 kB view details)

Uploaded CPython 3.10+Windows x86-64

iptocc-3.3.36-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (625.2 kB view details)

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

iptocc-3.3.36-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (625.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

iptocc-3.3.36-cp310-abi3-macosx_11_0_arm64.whl (621.1 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.3.36-cp310-abi3-macosx_10_12_x86_64.whl (615.1 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: iptocc-3.3.36.tar.gz
  • Upload date:
  • Size: 445.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.36.tar.gz
Algorithm Hash digest
SHA256 20f06ed0c6757c862968cc80f6c2474b8facaae5e014520966bff5d417fe993e
MD5 5f681e8db97fd6f61ffd48d7262b1e24
BLAKE2b-256 25907fbe80991cf8cd94bb49737449c51b4dfaeecb649c7efbb887e14d6d0e76

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: iptocc-3.3.36-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 513.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.3.36-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 05f9fb1ad1f2a5680abff811d373402e284f8f48758cc3c091e668e3999db170
MD5 dad69d586762ec05d0149703fe65f2b8
BLAKE2b-256 e57abdf815da9c18206344dbc70aeab1ba25e499b5784b6edffb09fe0fafe54e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.36-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e947ec0ddc7e095e73381b57d9eb79e143ad5e5c97a133a585ee642f785cbbb4
MD5 ae3e4e747adc70ee09f2796747fde5fd
BLAKE2b-256 d7f673f08670b3aa14089d9022997a4854c4aa63b0be120212e541d90a02be10

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.36-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 108dee772593bf63b1fbdb86398166c04301f5b1e9f6ca3b6f8c302e20f949b4
MD5 cb5b8513db4a20304d0516de04ad07bf
BLAKE2b-256 8af908e0302539c6d3f8dfca9f1504789a4cf48f6f02612352c676c488b5032a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.36-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9117b1703d6f9ffec07d5c38e17595e6a64e87dd39673813bbb1a192c18d6a39
MD5 b82851a4e79964979421373db5ea532c
BLAKE2b-256 d9893ed63d79983d6bb2618c34eb586a2f23199eda453c45cc1d1c06daf1725a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.36-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 574ae95e19194a745ad29dbfa9b91f0b1b50b973c4111f1e0bc449c1a7ba2d83
MD5 0856c8f8d325c72ff621c6a09c0527db
BLAKE2b-256 3b4943737311b436ee6b9f2545d504061e7da5454426697e8a3b6a1e1cb53822

See more details on using hashes here.

Provenance

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