Skip to main content

Country-aware Python client for AddressPerfect on RapidAPI. Offering postal code and street search, address normalization, and country-specific formatting. Lightweight, requests-based, and easy to integrate into applications and services.

Project description

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

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

postal_address_api-0.1.0.tar.gz (56.6 kB view details)

Uploaded Source

Built Distribution

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

postal_address_api-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file postal_address_api-0.1.0.tar.gz.

File metadata

  • Download URL: postal_address_api-0.1.0.tar.gz
  • Upload date:
  • Size: 56.6 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for postal_address_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8af4f6856a1a2444c5074087ecc202ec2f175a96e7dabd4c68d3889b99b38374
MD5 64119f2de1fc2dd1a74e7b9f78f7bf9c
BLAKE2b-256 9881900bf9c09b32e237a50b9fc0566ba857ff992b300201e6e169ac57c969a3

See more details on using hashes here.

File details

Details for the file postal_address_api-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: postal_address_api-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for postal_address_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 142f94d8f9dc3dd8fb8f4c5f873b3356e0afe4640f6e7b287ac782ece7ce9255
MD5 c61ea81e037fe2b58b017eaa438a414b
BLAKE2b-256 c500aa1a7761bb2973875f13a1f2072f679c4a9ad4c3762e2042f43721286398

See more details on using hashes here.

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