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.0.tar.gz (851.9 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.0-cp310-abi3-win_amd64.whl (931.1 kB view details)

Uploaded CPython 3.10+Windows x86-64

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

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.2.0-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.0.tar.gz.

File metadata

  • Download URL: iptocc-3.2.0.tar.gz
  • Upload date:
  • Size: 851.9 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.0.tar.gz
Algorithm Hash digest
SHA256 aa268f2a7265adb3fbf4321c1e50b926c90887fcf901c65970881aa126eb411d
MD5 75925abf5778a1971e7b40ee31651829
BLAKE2b-256 cd1402134825a35ec8d7b0b76301e2906abc36fbe1d416370bf69953a0b8aa20

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: iptocc-3.2.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 931.1 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.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 07fe3c55cdbd18682ad9e328e1887f5fc44e8a16d6b0b6eee4f4f92cbe943405
MD5 133f3d11e1811c1a0cba985091157096
BLAKE2b-256 de49274e1be19a53076af56e243d1a74defee0bea1a57990de8c3ea89526a494

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ce50b3d1b0c67bebe7e0287e10ffa2a606379378c7c886946008605c95b2b7d2
MD5 034d998b177f6c9ccbf6de0049bf0923
BLAKE2b-256 c441189120f4f9d340de0a521a96d5551dc085569dfb17b841f74f8374ce0cd6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 49b84ea7a21f7cfacc11db741b9815b9b1510769758e94000cda920464715d83
MD5 9cf7bb137dd752d05700b18ae084cb46
BLAKE2b-256 e39e6620b4f3c849f5c86ceb5f4078dbe08c09a3ada4013688cd42a5ca983e19

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c42b839322c97886892f44122bc652c50a067df4c05be2c966bc576f7be145af
MD5 2593433a8b32e50974677fef5282f64d
BLAKE2b-256 147b766bfb6d973138a7b346c3af1650bf888185ffedac1e48b5fb3d54d9a880

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.2.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1abf3a000cb0153bccc2e1ef107d7525c66e8e1897708780fd69640196782fce
MD5 8eb0b7f23eb6bfd267b3dc8e7c888a22
BLAKE2b-256 07e0e8354125b86780e14a57251beead530030174653bdf6d29acc0b38848322

See more details on using hashes here.

Provenance

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