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.2.tar.gz (852.3 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.2-cp310-abi3-win_amd64.whl (931.2 kB view details)

Uploaded CPython 3.10+Windows x86-64

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

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.2.2-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.2.tar.gz.

File metadata

  • Download URL: iptocc-3.2.2.tar.gz
  • Upload date:
  • Size: 852.3 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.2.tar.gz
Algorithm Hash digest
SHA256 aec1f65b81580b781bb4b5b722242a82426fb221d6066cac2da495b6be1c97b7
MD5 cba9ef853f7e2ecd393ad7d9ba8dd9f5
BLAKE2b-256 93f90b9903289e53719daa790b5b0424e7090f1822e227cbe18e572dda98eaa3

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: iptocc-3.2.2-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 931.2 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.2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9c8e49810d1a426eb44e5171a0e177a053f821f2b3626669781a53bc14552dad
MD5 e71b2b49e777626da6e8921a7d1f932d
BLAKE2b-256 deb98570e438989e2135b3ecad7cfa065caddfdd1ca8f238df707f8ae385fea2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b1b2cb7d112503ac4a66b7f724cdefa54814c9121c7b9cf85356c34ebde20e0
MD5 238545d83e4aa9da20f79e0120ac8d2d
BLAKE2b-256 de0e330233bd492d844bdd3695587c6b9b35cedcbbb9e8edd3743b28a5f6ce70

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 717182e332e93fe225f493b210c008bed7d96dd98646a5fd1595153c8d99fc03
MD5 d636983a710a85c49d1668fb731694e9
BLAKE2b-256 9a60e382a76427b37a6783fe8d4eb3e090dc271b04aa41e5e17879e76454a4fc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d7dcf9712b5a7d6be93653535e8b60a9bb2f6332b5eab842b65a3f86576aca93
MD5 e44dbd17ae8fb3868f6c8edeb7867615
BLAKE2b-256 f02d439496a7588fc37d5a6e2affe7174f3aeab4f67c4e3466a6a7fb6abeb5cc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.2-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ce1b90971cf06b073077b6f0edc35e92fbc108c5f70c3ed8b99e8dc30e027d66
MD5 ae2426ac73968cabbc630534a029902d
BLAKE2b-256 937b02163e955c24e32c7c850bdac965ccedbb7d1ef6bcec0114ce2731fa7788

See more details on using hashes here.

Provenance

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