iptocc
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
iptoccCLI installed withpip 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
- iptocc — the Rust crate this binding is built on
- @roniemartinez/iptocc — WASM/JavaScript bindings
- GitHub repo
Release files for iptocc 3.3.132
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| iptocc-3.3.132.tar.gz | 447.9 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| iptocc-3.3.132-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| iptocc-3.3.132-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| iptocc-3.3.132-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| iptocc-3.3.132-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| iptocc-3.3.132-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 3.5 MB
Release files / iptocc-3.3.132.tar.gz
| Download URL | iptocc-3.3.132.tar.gz |
|---|---|
| Size | 447.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd1720a84c37af588438053907706d6d6c5a9af1b29e2ed30d4f77da0c37956f
|
|
BLAKE2b-256 checksum How to use checksums |
c4870ce4f31593bafdfe915ae622ba1bd5e2d7718985c93db01be35055287857
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.
Transparency logRelease files / iptocc-3.3.132-cp310-abi3-win_amd64.whl
| Download URL | iptocc-3.3.132-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 521.9 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b61a2d21ad7c89ea987e50af8003d94ecd313140774ad7cab3a0e3e594dbb1be
|
|
BLAKE2b-256 checksum How to use checksums |
38c06b408478fd570d0edaa58d50ee73944c696d56cbe29fd5ec109df825a548
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.
Transparency logRelease files / iptocc-3.3.132-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | iptocc-3.3.132-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 631.5 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b6560faec0cf05caf21215befdec9ca5305818863a5afa3480e25c95043cd2f4
|
|
BLAKE2b-256 checksum How to use checksums |
770574e7e55c90aca08b675c7c000c9ca48994195c17dee0e57b60421193135b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.
Transparency logRelease files / iptocc-3.3.132-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | iptocc-3.3.132-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 631.6 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
112d89b86600f24145b2ff708f5931c83e80435ae12f7903362132ef2d2fc062
|
|
BLAKE2b-256 checksum How to use checksums |
873fbfa36007812a8c00bd35f70d7858c0d0fa90b485e139cacba2ee3c2c90df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.
Transparency logRelease files / iptocc-3.3.132-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | iptocc-3.3.132-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 620.9 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
72b1a02a2f78b0a791aa32b0e7a36bd89778aeb3e60ecfc00025ac40509c6845
|
|
BLAKE2b-256 checksum How to use checksums |
6967d717b7a889ef64e502e87bfaacd24075bd4605921f7b96e0df7a4c556373
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.
Transparency logRelease files / iptocc-3.3.132-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | iptocc-3.3.132-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 620.4 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
3774484aa41ffab9cce1c9f83823fc12a37584ea08712f3d457d2df73f677a82
|
|
BLAKE2b-256 checksum How to use checksums |
b1048d1685bf793886def5f7f015a781935fa26101576abb688e793e88d7a341
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.
Transparency log