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.0.tar.gz (6.0 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.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for postcode_eu_api_client-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7b3be7ea832bbb844bbd4ab40c5e3393f4bb1a6ba17b09609ac4294e72f9164f
MD5 e6ab9bfd271734c379ef5cf4d801e158
BLAKE2b-256 025d192b034927dcb33c8c9a9bba292ecb700bc4722a67916d1765d9ee58ce8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for postcode_eu_api_client-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e777526fd9ade5f1c836eaa1c7f8aa61c6b7c8a31969c19b50a249b4149a2950
MD5 99083a75795b25456054b2289a66811a
BLAKE2b-256 b8c2d9f21bd5bbee7a1f3ecf345ec5f41dc5e6441647f72c9759655d05c10969

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