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.1.2.tar.gz (1.8 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

iptocc-3.1.2-cp310-abi3-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10+Windows x86-64

iptocc-3.1.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

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

iptocc-3.1.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

iptocc-3.1.2-cp310-abi3-macosx_11_0_arm64.whl (2.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.1.2-cp310-abi3-macosx_10_12_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for iptocc-3.1.2.tar.gz
Algorithm Hash digest
SHA256 d5515bb99fe94a90acadf5de91d406ca3759808921e2bea33590684f245f8314
MD5 8c11946e651ee741059bc9de71710396
BLAKE2b-256 89281251866c46bb76ad86eba008abbfee9f04e7fe5a0f4500181f44fb37409c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: iptocc-3.1.2-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • 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.1.2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 efef8e810ceaee07d35ad16cf324b54392962d37a0b965a0004fee010ce906f5
MD5 a32ae7f710a5cc9965d733a07eec7b21
BLAKE2b-256 bc646c33da130a8e6db590a660753cf8d42bf5484898a30b15ec8c890dbe1599

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.1.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 27096a2af99e25207dcfde42bf67114a348cd3e532547114170e7b5a0a983064
MD5 367a78be70a505bbaeb51234eaf07dda
BLAKE2b-256 b33110ce7a99d4a617b4f70940a7d8816de565acf7961ef5ae441b121914f601

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.1.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ce9ceacf833f799d8b4d89e7c6bbceee1677b68d63aac296bfc3e3e459ab9c43
MD5 5aacc69a5653c5792eaa7ef477a38241
BLAKE2b-256 085b72dd697c1ce43a4a7ac5e7254013f06145f93c684f5b4329b4605d10f511

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.1.2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5cae5c61c678282ec42c85fbda68ed2e4b471b657d617fdccb9879f4b1304934
MD5 04017617c510209dcb513995a84a8bed
BLAKE2b-256 3629a7b7260adfb80bd13f064456b5cced44eca445147fd407cbb181ffe29854

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.1.2-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 916c71adf33c03d80465832878d7d242be4d9f40e6b531903218aee1424a34ec
MD5 1a17f941a550ea0050abc7d1116d9e01
BLAKE2b-256 b987c7fa9dfc803c718e1f91c83c27390bd635702a6a26b1dbcfe4d7fc03c9b5

See more details on using hashes here.

Provenance

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