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) but is roughly 65,000x faster on bulk workloads and adds a batch API. 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.0.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.0-cp310-abi3-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10+Windows x86-64

iptocc-3.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB view details)

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

iptocc-3.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.1.0-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.0.tar.gz.

File metadata

  • Download URL: iptocc-3.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 2108296c45386ce92ea84e74b4cb945d171120abb115f2d5b2d5fb655b13bb3c
MD5 336769cf79bcf75647b32f7421f45c0e
BLAKE2b-256 1b435eca23cc4cbd0a85d46c840c31c7d9fcd7b6c7e699f1e9768937f8dc33c9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: iptocc-3.1.0-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.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 bad1505d43f8cf9eec138778219fdffa5026034ec3b84dd857c68ee1e26eef69
MD5 996053878dcec50a3d9758e1ad141054
BLAKE2b-256 1b8dab17176f037ccdfc0b4e70d15713a4073e60bbb2dc31239a508df9d31e36

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7316a8b0c73c037c1869aab43bae2061a8e4b211c5e3c49f589cf853179a4064
MD5 3a73a839ad45cb2538087fb2f3b74334
BLAKE2b-256 37aa8ffdc54fc79a013214e5971aa25e29692c1309c0e07cfaabefa525f92960

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f4228750a73e2aa351c7a43dd366d1a1690c2a2e72e3e7667384561b8c3f866c
MD5 a9972dc44895c76b02b49f8e81609da2
BLAKE2b-256 1d23ad6fd4cf8dcc1c0d13524a6a5bde9d25b455c92dd3bc9e89458c26c30cf8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.1.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1e70ac9d0cf7acf063ca572141fe78094064c27b40581eb77168545916a98454
MD5 22af4112bed705a88606a8c60a96086b
BLAKE2b-256 d674a0dfdeac3cfae0c141f701276f35c511121f0acc6426e64dd6db530e745d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7456f3c31dcb7ac2fd850296753d7f44ccc81a730479f4d15ae3c41d064cb1db
MD5 a1a3baa3290be622ecbb57e73f28138c
BLAKE2b-256 75f202f8612ba4d96d377a2f34fdaab8fb6055f14345918df06730c67832e5e0

See more details on using hashes here.

Provenance

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