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 addressinternational_get_details()- Get address detailsinternational_get_supported_countries()- List supported countries
Dutch Address Addresses
dutch_address_by_postcode()- Lookup by postcode and house numberdutch_address_rd()- Lookup by RD (Rijksdriehoeksmeting) coordinatesdutch_address_lat_lon()- Lookup by latitude and longitudedutch_address_bag_number_designation()- Lookup by BAG Number Designation IDdutch_address_bag_addressable_object()- Lookup by BAG Addressable Object IDdutch_address_postcode_ranges()- Lookup streets and house number ranges by postcode
Validate Addresses
validate()- Validate international addressesget_country()- Get country information
Accounts
account_info()- Get account informationcreate_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 exceptionsAuthenticationException- Authentication failed with the APIBadRequestException- Bad request sent to the APICurlException- 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 APIInvalidJsonResponseException- Invalid JSON response received from the APIInvalidPostcodeException- Invalid postcode format providedInvalidSessionValueException- Invalid session value providedNotFoundException- Resource not foundServerUnavailableException- API server is unavailableTooManyRequestsException- Too many requests sent to the APIUnexpectedException- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file postcode_eu_api_client-1.0.0.tar.gz.
File metadata
- Download URL: postcode_eu_api_client-1.0.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b3be7ea832bbb844bbd4ab40c5e3393f4bb1a6ba17b09609ac4294e72f9164f
|
|
| MD5 |
e6ab9bfd271734c379ef5cf4d801e158
|
|
| BLAKE2b-256 |
025d192b034927dcb33c8c9a9bba292ecb700bc4722a67916d1765d9ee58ce8a
|
File details
Details for the file postcode_eu_api_client-1.0.0-py3-none-any.whl.
File metadata
- Download URL: postcode_eu_api_client-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e777526fd9ade5f1c836eaa1c7f8aa61c6b7c8a31969c19b50a249b4149a2950
|
|
| MD5 |
99083a75795b25456054b2289a66811a
|
|
| BLAKE2b-256 |
b8c2d9f21bd5bbee7a1f3ecf345ec5f41dc5e6441647f72c9759655d05c10969
|