Skip to main content

Python client for the Postcode.eu API

Project description

Postcode.eu API Python Client

A Python client library for the Postcode.eu API, providing access to international address autocomplete, Dutch address lookup, and validation services.

Installation

uv add postcode-eu-api-client
# Or
pip install postcode-eu-api-client

Quick Start

from postcode_eu_api_client import Client

# Initialize the client
client = Client('your_api_key', 'your_api_secret', 'YourApp/1.0')

# International address autocomplete
import secrets
session_id = secrets.token_hex(16)
result = client.international_autocomplete(
    context='nld',
    term='den',
    session=session_id
)

# Dutch postcode lookup
address = client.dutch_address_by_postcode('1012JS', 1)

# Validate international address
validation = client.validate(
    country='bel',
    postcode='2000',
    locality='antwerpen',
    street='leystraat'
)

API Methods Overview

International Addresses

  • international_autocomplete() - Autocomplete an address
  • international_get_details() - Get address details
  • international_get_supported_countries() - List supported countries

Dutch Address Addresses

  • dutch_address_by_postcode() - Lookup by postcode and house number
  • dutch_address_rd() - Lookup by RD (Rijksdriehoeksmeting) coordinates
  • dutch_address_lat_lon() - Lookup by latitude and longitude
  • dutch_address_bag_number_designation() - Lookup by BAG Number Designation ID
  • dutch_address_bag_addressable_object() - Lookup by BAG Addressable Object ID
  • dutch_address_postcode_ranges() - Lookup streets and house number ranges by postcode

Validate Addresses

  • validate() - Validate international addresses
  • get_country() - Get country information

Accounts

  • account_info() - Get account information
  • create_client_account() - Create client account (resellers only)

View full documentation at https://developer.postcode.eu/documentation.

Exception Handling

The client provides specific exceptions for different error conditions:

from postcode_eu_api_client import Client, InvalidPostcodeException, AuthenticationException

client = Client('key', 'secret', 'platform')

try:
    result = client.dutch_address_by_postcode('invalid', 1)
except InvalidPostcodeException as e:
    print(f"Invalid postcode format: {e}")
except AuthenticationException as e:
    print(f"Authentication failed: {e}")

Available Exceptions

  • PostcodeEuException - Base exception for all Postcode.eu API client exceptions
  • AuthenticationException - Authentication failed with the API
  • BadRequestException - Bad request sent to the API
  • CurlException - HTTP request error (equivalent to cURL error in PHP)
  • CurlNotLoadedException - HTTP library not available (equivalent to cURL not loaded in PHP)
  • ForbiddenException - Access forbidden by the API
  • InvalidJsonResponseException - Invalid JSON response received from the API
  • InvalidPostcodeException - Invalid postcode format provided
  • InvalidSessionValueException - Invalid session value provided
  • NotFoundException - Resource not found
  • ServerUnavailableException - API server is unavailable
  • TooManyRequestsException - Too many requests sent to the API
  • UnexpectedException - Unexpected response from the API

Requirements

  • Python 3.10+
  • A postcode.eu account. Register your account at account.postcode.eu. You can test our service for free.

Examples

This repository includes examples for each API method. See examples/README.md for usage.

License

The code is available under the Simplified BSD License, see the included LICENSE file.

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

postcode_eu_api_client-1.0.2.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

postcode_eu_api_client-1.0.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file postcode_eu_api_client-1.0.2.tar.gz.

File metadata

File hashes

Hashes for postcode_eu_api_client-1.0.2.tar.gz
Algorithm Hash digest
SHA256 785b9cbf0f47a60c8f49f6596d46c490eb4a10dc9bb47469eed3873d5987e8a5
MD5 59818e3d4e3fd37be6164947e79f1237
BLAKE2b-256 1aebb8b4d5b2a4056bee683a67723a16b809afa9f6115b4e8b5bc79098e78b91

See more details on using hashes here.

File details

Details for the file postcode_eu_api_client-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for postcode_eu_api_client-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 817f8fe97201bc0c480b6cbc886295991a5f155253204b4ed868455651420aeb
MD5 ed8a075de4ba3793fc1f7fcd045df913
BLAKE2b-256 ba47fe53a98a95f0adbe3054de252a1efadcc1fd6c1696b0c5988047876a6b29

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