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.12.tar.gz (444.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.3.12-cp310-abi3-win_amd64.whl (512.8 kB view details)

Uploaded CPython 3.10+Windows x86-64

iptocc-3.3.12-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (623.2 kB view details)

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

iptocc-3.3.12-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (623.9 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.3.12-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.12.tar.gz.

File metadata

  • Download URL: iptocc-3.3.12.tar.gz
  • Upload date:
  • Size: 444.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.3.12.tar.gz
Algorithm Hash digest
SHA256 33c42aea30a9158e5d83049ff133601550deb93df41c825adf5206437904ae94
MD5 d6fe7b746592a7153b087c4c0179ba89
BLAKE2b-256 c81a75993b662ea4e669ec19d4548a9589c26167a633fc2943b43fcd753c12ca

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: iptocc-3.3.12-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.12-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 55ed810ffbd1af2aa293efccb930fbfba2f6fb11dee0de4d1865cc724abecdb6
MD5 aea51772aa5a431d7aed2f5206ab5a84
BLAKE2b-256 ce66d5ab42c82b1cf760a0324525222dc9ea816d1fc543b389f0676bbab35f47

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.12-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 38d5961b39987da2515db4d08b77069da22c5e5e9f7198c8959b5a7f874b8826
MD5 d8594a6b7c3063c4e2d2212361dcc5d8
BLAKE2b-256 5c3ca8da9f32c6e5679f3da748dd2a935c1ea4c4ff415338ccf5b6594f0613cd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.12-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a57484c429da0d87861934db5c993b54a0a9ef410d03d4a0e0d7cef9b549f523
MD5 678c90fb491cf1a1cf3cb26a6b4a8285
BLAKE2b-256 54ba60a503eb902c8642d8313c91b19edd7497a84ac02e1523cb1b2a61549179

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.12-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f1b1dce2e98157141b423e15bc17e5dbe721e95640e63ea901ad7ef3651bce73
MD5 e48be958c4824f1044f74b8fa7dbdf56
BLAKE2b-256 a299e7fef02175337a1ef7454acdcdfc8d0dda71158159ab27ebdf2d661777dd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.12-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1dfcbd5e0e762f506788f772601f93c89af7c350df2da496b0d2904647926847
MD5 d69718849f8cf2c87fa899618b63e08b
BLAKE2b-256 9538ff91b163e2ba324f76ef82d5bf1bf204929f99076e3a561e467253fa0bb5

See more details on using hashes here.

Provenance

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