Skip to main content

postal-address

Python package for country-aware street/address autocomplete and validation using AddressPerfect APIs on RapidAPI.

Features

  • Single codebase for multiple countries
  • Country selected via one constructor parameter
  • API key from env var (RAPIDAPI_KEY) or constructor argument
  • Wrapper methods for all main endpoints from the API spec

Supported countries

  • de German Streets API
  • sk Slovak Streets API
  • nl Dutch Streets API
  • fr France Streets API
  • cz Czech Streets API
  • ch Swiss Streets API
  • be Belgium Streets API
  • at Austrian Streets API

Installation (uv)

uv sync

For development dependencies:

uv sync --extra dev

API key setup

Option 1: set environment variable

export RAPIDAPI_KEY="your_key_here"

Option 2: pass key directly to the client constructor.

Usage

from postal_address import PostalAddressClient

client = PostalAddressClient(country="de")

# Full-text autocomplete
results = client.autocomplete("Elisabeth")
print(results)

# Street-only autocomplete
streets = client.get_street_list("Elisab", zip_code="80797", city="München")
print(streets)

Running tests

uv run pytest

Examples

The examples/ directory contains fully-working code samples for common use cases. All examples focus on Swiss addresses (country code ch) to demonstrate integration patterns.

1. Django Registration Form with Autocomplete

Location: examples/django-registration-form/

Real-time address autocomplete for a Django user registration form:

  • Form with Swiss address fields
  • AJAX endpoint for autocomplete suggestions
  • Address validation on form submission

Quick Start:

cd examples/django-registration-form
pip install -r requirements.txt
# Configure RAPIDAPI_KEY, then integrate into your Django app
export RAPIDAPI_KEY="your_key_here"
python manage.py runserver

2. Batch Excel Processing

Location: examples/batch-excel-processing/

Validate customer addresses in bulk from an Excel file:

  • Reads customer data from Excel (XLSX)
  • Validates each address against the Swiss API
  • Normalizes address components (street, postal code, city)
  • Outputs results with color-coded validation status
  • Detailed error reporting

Quick Start:

cd examples/batch-excel-processing
pip install -r requirements.txt
python create_sample_data.py
python batch_address_validator.py sample_customers.xlsx validated_customers.xlsx

3. FastAPI Address Validation Endpoint

Location: examples/fastapi-validation/

REST API for Swiss address validation and autocomplete:

  • POST /register - Validate and register users with Swiss addresses
  • GET /autocomplete - Get autocomplete suggestions
  • GET /users/{user_id} - Retrieve stored user registrations
  • Interactive Swagger documentation at /docs

Quick Start:

cd examples/fastapi-validation
pip install -r requirements.txt
python -m uvicorn main:app --reload
# Open http://localhost:8000/docs

Package layout

  • postal_address/ package implementation
  • tests/ unit tests
  • examples/ documented code examples (Django, batch Excel, FastAPI)
  • pyproject.toml build and dependency config

Metadata

Release files for postal-address-api 0.1.0

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

Source distribution (sdist)

Source distribution for postal-address-api 0.1.0
File Size Uploaded
postal_address_api-0.1.0.tar.gz 56.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for postal-address-api 0.1.0
File Interpreter ABI Platform
postal_address_api-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 61.8 kB

Release files / postal_address_api-0.1.0.tar.gz

Download URL postal_address_api-0.1.0.tar.gz
Size 56.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8af4f6856a1a2444c5074087ecc202ec2f175a96e7dabd4c68d3889b99b38374
BLAKE2b-256 checksum
How to use checksums
9881900bf9c09b32e237a50b9fc0566ba857ff992b300201e6e169ac57c969a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / postal_address_api-0.1.0-py3-none-any.whl

Download URL postal_address_api-0.1.0-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
142f94d8f9dc3dd8fb8f4c5f873b3356e0afe4640f6e7b287ac782ece7ce9255
BLAKE2b-256 checksum
How to use checksums
c500aa1a7761bb2973875f13a1f2072f679c4a9ad4c3762e2042f43721286398
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.16 {"installer":{"name":"uv","version":"0.11.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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