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.38.tar.gz (445.1 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.38-cp310-abi3-win_amd64.whl (513.7 kB view details)

Uploaded CPython 3.10+Windows x86-64

iptocc-3.3.38-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (625.2 kB view details)

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

iptocc-3.3.38-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (625.3 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

iptocc-3.3.38-cp310-abi3-macosx_11_0_arm64.whl (621.3 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.3.38-cp310-abi3-macosx_10_12_x86_64.whl (615.2 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: iptocc-3.3.38.tar.gz
  • Upload date:
  • Size: 445.1 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.38.tar.gz
Algorithm Hash digest
SHA256 be6e4e42cc6ca9d6faa5da1102691297d4de279d2a81f9302a43e02bf030e89b
MD5 f33ac071952a16d37b3b15ec2b92ff26
BLAKE2b-256 069898d87a3b1c1a2431a573799c25162adaf2969316e9263fffcac8fb3abd9e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: iptocc-3.3.38-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 513.7 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.38-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e10552b63008fcdab84c5c4f17d2b6084b13bb894ef643ba466b4be07521bb3a
MD5 f5d7ca7100305c888cf6c2ae68585d4f
BLAKE2b-256 55143da6d6e28d45e780b914c31a926ad92ba8a56ffb326b67ffab1589edf862

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.38-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab40e569a1b9a85393399a7aabf47f83e8bd8c39f76fb46b0dfc159d2aa3bef7
MD5 f15801eb7ca93e9ee6b0d0727c5a8630
BLAKE2b-256 a11e0926992f142d9947df23faea3f78915ef16d7aebcc3bd5ebe64b59058887

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.38-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c3e9304780ffbc4c66188407072d36f16439d9e16d0724773adb3359ef69f535
MD5 29208b90886ea295cd8a35c719bbb835
BLAKE2b-256 d7d39650e4b9432d3a20ab958c67499a63d38add0e9ae30db24ae99d2ede6ef8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.38-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e348d6eefbd407f8e8368ae0adba55fd478a53f140abad76452edc301ae732f6
MD5 bce2d68f996f78db1432101d864417f7
BLAKE2b-256 a4366e60bbbc99a228688ccdcadae2168b9abbdb2d69978ff6ac73ef1bf44194

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.38-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 730e1b4606192814f77cb646cf1637642c9253e7e0873cd74f8fe43835cb324a
MD5 3a842a9c3dc0b1112f9e5593facfdbcb
BLAKE2b-256 a5a732636b8b85bed2503d7269f5b528901a545d6ca01bfe124442f6e8228878

See more details on using hashes here.

Provenance

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