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.0.0.tar.gz (1.3 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.0.0-cp310-abi3-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.10+Windows x86-64

iptocc-3.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

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

iptocc-3.0.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

iptocc-3.0.0-cp310-abi3-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

iptocc-3.0.0-cp310-abi3-macosx_10_12_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for iptocc-3.0.0.tar.gz
Algorithm Hash digest
SHA256 c23d73aa991b4cf3b0fbe61c2d771afefa50b97c6fe03a0e0e3b2974a9056847
MD5 b99b04a4c3f2908a104c97d1075fe4ab
BLAKE2b-256 a786c348e365626308b7e05bf867b5d9311d0bd5cda54148f3e3e7060d40069b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: iptocc-3.0.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.4 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.0.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7e93710cf678bcd9e4367781abe77e7c012ad1013689592b910611216f0e851b
MD5 223e423c6ab16040c5af736d6031b131
BLAKE2b-256 058d5da446fec034d9afeccd64455c87a3105cab0ecf35732991a365738911ec

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 345dee21f930a846396c7076a3aa00e418ba86a8a086a9f53a07c1f1633d4d8d
MD5 c9481eac25ce3c9686d0098896881377
BLAKE2b-256 68b1219f50840a80f17b056ee9c0b44443db3cd378c1da09c1be503a467a6463

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.0.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f7eeaa1077fdb325379d0e42078e5ec2459b5c6879299d44143e1c0b867a9701
MD5 b550775d348e0e0ac14885fe57c03a94
BLAKE2b-256 6e1da6bd5b6574ba9f795c774184720ee06992a851b5a204a278901297dee1b0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.0.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92deff579bcc9e259293e7527b1d1484cd3b9b152d2cc3a6fb1a5cc6899f43f1
MD5 7a77049cbe32fdd38b414b807f17aa5b
BLAKE2b-256 0c940ce58a7502e64998ff99dd600e73ad01a45dcdc1d6a054c91ed98bdc7c69

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for iptocc-3.0.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2cd3c453d309420fe8da011e53cdd1b18cc93a30584b1e1a324d0b7ce6912a87
MD5 4d7304aff5235988eaa99e42ab510347
BLAKE2b-256 8b14af16eb280edb4dec10edb60b53154d245beb62b4b366a1e66271532910df

See more details on using hashes here.

Provenance

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