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.16.tar.gz (445.0 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.16-cp310-abi3-win_amd64.whl (512.9 kB view details)

Uploaded CPython 3.10+Windows x86-64

iptocc-3.3.16-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (623.4 kB view details)

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

iptocc-3.3.16-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (624.0 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

iptocc-3.3.16-cp310-abi3-macosx_11_0_arm64.whl (620.4 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.3.16-cp310-abi3-macosx_10_12_x86_64.whl (614.7 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: iptocc-3.3.16.tar.gz
  • Upload date:
  • Size: 445.0 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.16.tar.gz
Algorithm Hash digest
SHA256 5e9b13d62f0b2944f67ff896bdc62339dcde3c9e14672262c46097542c7de050
MD5 74b45d229e24099d4dbcf4d5ccb35174
BLAKE2b-256 93b5637cd168f7081435856b6ae6ca49e03e56d8c1f6d7630a99f60f1342eec3

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: iptocc-3.3.16-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 512.9 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.16-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0c58b19afc6977b761e1db3e78c9a894129a0d22af0fe1447c424066db157092
MD5 71d80f8a09d3719b423352ca56d21b5c
BLAKE2b-256 80a00c06f7735adcfefffdbb371f701cd6b6b7333dd22eb3950177b67e080eed

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.16-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6e72fffc5293c77de5c8c2efad261d8f0991cafa619ab5d03de29863961b799d
MD5 29aa1c7a22c770e005e0e29c6c2d0d04
BLAKE2b-256 e9c2820404e76f6f174ff1ebe0fd171a23c012417b541a06a6fa17ffb3a87db8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.16-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 449ba01476e660a660b7cd32fb7f45ed1320fbeca551abb024745149936c6531
MD5 3a9d03081827187aa8064d3846db27c2
BLAKE2b-256 6f6b60ae12f1c9ffa0d40e80f2c76e674aad9b7f275c49487ad88aff0ed3d7c1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.16-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1e6890749a45ae3ab58ae1ae071a4fc8991313d12e9c04fccb7d3f3e95dfbfe3
MD5 e45bbf172a6717588a848cd7fe50bc03
BLAKE2b-256 163c05cbaee7242f6b7367a28911fab18625a64301109e0d83aba0da4d09dc76

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.3.16-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fb8bae6e62a13fe0465d33fe138808628b456a6ac876ff77207562aafd0227db
MD5 5e8a172fbbbe7a168d56d0a590397df9
BLAKE2b-256 fa97c3f31289296d364a7520dfbb55bb50edc889c16fa5d5a60cc7f439d3c533

See more details on using hashes here.

Provenance

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