Skip to main content

PostalKit

PyPI version Downloads Python Versions License: MIT Wheel Status

Zero-setup, one-command install Python package for libpostal. Designed as a strict 1:1 C-FFI wrapper.

Parsing international street addresses shouldn't require a Ph.D. in C compilation. postalkit provides the ultimate zero-friction environment to run the amazing libpostal C library natively in Python, without abstracting away its raw power.

Like FFI implementations in PHP, this exposes the exact C structs, constants, and functions so that you can port C logic directly to Python.

✨ Why PostalKit?

The standard postal package requires you to manually compile C code, install autoconf, make, pkg-config, and manually download a ~2GB machine learning model.

PostalKit handles everything automatically:

  • ✅ Zero C compilation: Downloads pre-compiled libpostal shared binaries for your OS and architecture.
  • ✅ Auto-downloads models: Fetches the required libpostal ML models transparently on first use.
  • ✅ Strict 1:1 C Mapping: Exposes libpostal_parse_address, libpostal_expand_address, and all ctypes structs exactly as defined in libpostal.h.
  • ✅ Cross-platform: Works on Linux (x86_64, arm64), macOS (Intel, Apple Silicon), and Windows.

📦 Installation

pip install postalkit

🚀 Quickstart

Because this is a true 1:1 FFI wrapper, you use the exact function names and C-structs defined in the upstream libpostal C headers. Memory is managed precisely as it is in C.

import ctypes
import postalkit

# 1. Get the C-struct for parser options
options = postalkit.libpostal_get_address_parser_default_options()

# 2. Call the C-function directly (strings must be passed as bytes)
address = b"221B Baker St London"
response_ptr = postalkit.libpostal_parse_address(address, options)

# 3. Access the raw C-arrays
response = response_ptr.contents
for i in range(response.num_components):
    component = response.components[i].decode('utf-8')
    label = response.labels[i].decode('utf-8')
    print(f"{label}: {component}")

# 4. Manually destroy the C pointer to free memory, exactly as in C!
postalkit.libpostal_address_parser_response_destroy(response_ptr)

🧠 True 1:1 FFI Coverage

This package leaves absolutely nothing behind. It natively exposes:

  • All 46 C functions (libpostal_tokenize, libpostal_classify_language, libpostal_is_name_duplicate_fuzzy, etc.)
  • All 10 C Structs (libpostal_normalize_options_t, libpostal_duplicate_options_t, etc.)
  • All 42 C Constants & Bitwise Flags (LIBPOSTAL_ADDRESS_HOUSE_NUMBER, LIBPOSTAL_NORMALIZE_TOKEN_DELETE_HYPHENS, etc.)

You can directly port any libpostal C/C++ tutorial code into Python line-by-line.

🛠️ Advanced Usage

Pre-downloading assets (e.g., for Docker images or CI):

from postalkit.data.manager import ensure_all_assets
ensure_all_assets()

📄 License

MIT License. Developed with 💙 by Jayesh Mepani.

Metadata

Release files for postalkit 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for postalkit 1.0.7
File Size Uploaded Provenance
postalkit-1.0.7.tar.gz 8.8 MB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for postalkit 1.0.7
File Interpreter ABI Platform
postalkit-1.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 17.7 MB

Release files / postalkit-1.0.7.tar.gz

Download URL postalkit-1.0.7.tar.gz
Size 8.8 MB
Tags Source
SHA-256 checksum
How to use checksums
2acf45c50ff45262097aa9ae449257b2a33e11b827fee1fff8ae2631e5c4cdb3
BLAKE2b-256 checksum
How to use checksums
cc86339dc1a14ddf5782ffb2a6827e5537294e70481224ca81b4f5ce68401ba1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 1, 2026.

Transparency log

Release files / postalkit-1.0.7-py3-none-any.whl

Download URL postalkit-1.0.7-py3-none-any.whl
Size 8.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
8b20f376fc94fed393450f086cbf318580fe2da288cddb83c25b4d078cb59dae
BLAKE2b-256 checksum
How to use checksums
f8640e9b9074ff9a19f42bea9948f8d70c29d93287a4b990880fd2be0e4e7700
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 1, 2026.

Transparency log

Security for postalkit 1.0.7

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for postalkit-1.0.7.tar.gz

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 May 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page