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.1.1.tar.gz (1.8 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

iptocc-3.1.1-cp310-abi3-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10+Windows x86-64

iptocc-3.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

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

iptocc-3.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

iptocc-3.1.1-cp310-abi3-macosx_11_0_arm64.whl (2.1 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.1.1-cp310-abi3-macosx_10_12_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: iptocc-3.1.1.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for iptocc-3.1.1.tar.gz
Algorithm Hash digest
SHA256 ac4d85b22c9e3ac8304569d829591a75418d19a78c4f915da3a9bb21b9f2bfd7
MD5 83f1cfd94aa9d823d89c43ee594668c7
BLAKE2b-256 6903acdebd42f958cfc2498675f2098457594a3a08c7ce4ced6933df4b1d9246

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: iptocc-3.1.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.9 MB
  • 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.1.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f7c4fe7750fe0b48e52a396ae96aab4979e831b311519cf2e20012befab28e72
MD5 117cd0da1e7a5e6cb2a9ece806ca9de6
BLAKE2b-256 948a20d91566dfba7fdae9925f1286001107eec5f7bfc6570772bbcd076dc8df

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dd7d8156859dea79202a933bf869406de957c376e684190f0c60ea21047876b3
MD5 2016816308a010f1a4cd5e362e87e281
BLAKE2b-256 eeeda9981ad8f40259486dc9ff3ed4dbfccddbda79cab113b6675df55bd98219

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 45c482b9c108c6ba17282d6de167edb0b48fce3cd92f418424f02a900d646695
MD5 6082debca84d63ec70e01d302e69c714
BLAKE2b-256 688c8a9cb8fdf1903f3d8f03c193f4cdb9f2745151321ddc30ae3c441bfb2a58

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.1.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 27fd89aac752d4ab4cf4447194dd295c6f568eeba44ff2c6f4bca460af21f659
MD5 ab00e9604df76bfffcefef9c0b0bcdaa
BLAKE2b-256 ee3c61e2bfad82c380fa2ecde36cc41b195eb5b46e06a3a7f1a01e11fec67486

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.1.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 490ebdfb2f9b513a5f2027ca115e5ea2b2e0a67c573fa34b230bf0f2fb6688ac
MD5 5c0be661caaaf29bbd46f84b81c1bd88
BLAKE2b-256 64d57aed28057383cf27d15875e05c08f256d66d0b0d8d8274b0aafa5f71a5c8

See more details on using hashes here.

Provenance

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