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.13.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.13-cp310-abi3-win_amd64.whl (512.8 kB view details)

Uploaded CPython 3.10+Windows x86-64

iptocc-3.3.13-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (623.3 kB view details)

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

iptocc-3.3.13-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (624.0 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

iptocc-3.3.13-cp310-abi3-macosx_11_0_arm64.whl (620.3 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.3.13-cp310-abi3-macosx_10_12_x86_64.whl (614.6 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: iptocc-3.3.13.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.13.tar.gz
Algorithm Hash digest
SHA256 036d123ecaeb97548ef846eb0b80d8c6733bd1dff5e9da28a2c66e35957d6f38
MD5 c998630cc50b909cb6057711b6214132
BLAKE2b-256 2bf1219c09e52db295dce825663f54ab4c47ea635455b5525f1881bb8ac3459d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: iptocc-3.3.13-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 512.8 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.13-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 450771b33f3bc20fa76afff4bb494de6223ff5330599d2cbeaf19838c107088b
MD5 545be83e999fd1458af8e42c9b1e6b43
BLAKE2b-256 228b29f69a825d3c099599b8fea06f7724a210097624caa2e80ef0f8deb1fc30

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.13-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5740e3263c0e696004a83cce6aeeda6abfcabbe8f4eb4ddcca185e3191ce0064
MD5 e9d0b0c6dc28e2daa8ab5df277449351
BLAKE2b-256 5bc0963965252db6e7388094fb140e9b739018087faa04fd887a0969bf6b5486

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.13-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 afaa8c5620589c7b09f7e0f037f995b6e3a7a73882549a897a2f7f45bdc155fe
MD5 d1ea8d2c98422ff25a88f88c47a2aad6
BLAKE2b-256 1263ce3fdb151a9153c72f2deefb3bdeeee3c944e08f4197d7d414f9e8184dd2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.13-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e15e77937cd2a32322ad2bc2e093c7c8188deae87bf68e3d24dd9e68b2528d6
MD5 7321ea69767bf1386151dffffb8bd558
BLAKE2b-256 f1427bfdb2bc774e1e4342e2e400de90484ba478602a334a55430e2cea771816

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.13-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c87c921c8132c4463a5bc5fbb8cf82f7f116e1933f33996161a57cc1a1d64245
MD5 8fb6ac2308d247e3a48d9592d16e7032
BLAKE2b-256 d8d056c9b6545919bcd8b7ce68d4f09e1637baed290d3d162b71523a52c019b2

See more details on using hashes here.

Provenance

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