Observed since 20 Oct, 19:21 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
A Python client for the Canada Post AddressComplete API
A clean, Pythonic client for the Canada Post AddressComplete API. Simplify address autocomplete and validation in your applications with type-safe error handling and an intuitive interface.
pip install addresscomplete
from addresscomplete import AddressComplete
client = AddressComplete("your-api-key-here")
results = client.find("123 Main St, Toronto")
pip install addresscomplete
Or install from source:
git clone https://github.com/dellwood546/AddressComplete.git
cd AddressComplete
pip install .
Requirements: Python 3.7+ and the requests library (installed automatically).
Get your free API key from Canada Post AddressComplete, then start using the library immediately.
from addresscomplete import AddressComplete
# Initialize the client with your API key
client = AddressComplete("your-api-key-here")
# Search for addresses
results = client.find("123 Main St, Toronto")
print(results)
# Retrieve detailed address information
address_id = "CA|CP|ENG|3X1-R2J"
details = client.retrieve(address_id)
print(details)
from addresscomplete import AddressComplete, FindError, RetrieveError
client = AddressComplete("your-api-key-here")
try:
# Search with custom parameters
results = client.find(
search_term="123 Main Street",
country="CAN",
max_suggestions=5,
language_preference="en"
)
# Process and enrich results
for item in results.get("Items", []):
print(f"{item.get('Description')} (ID: {item.get('Id')})")
# Retrieve complete address details
try:
details = client.retrieve(item["Id"])
print(f"Complete address: {details}")
except RetrieveError as e:
print(f"Retrieval failed: {e}")
except FindError as e:
print(f"Search error: {e}")
AddressComplete(api_key)Creates a new client instance.
Parameters:
api_key (str): Your Canada Post AddressComplete API keyfind(search_term, country="CAN", max_suggestions=10, language_preference="en")Searches for address suggestions matching the search term.
Parameters:
search_term (str): The address search termcountry (str, optional): Country code, defaults to "CAN"max_suggestions (int, optional): Maximum results to return, defaults to 10language_preference (str, optional): Language code (2 or 4 digits), defaults to "en"Returns: dict - JSON response with address suggestions
Raises: FindError - When the API returns an error
retrieve(id)Fetches complete address details for the given ID.
Parameters:
id (str): Unique address identifier from find() resultsReturns: dict - Complete address information
Raises: RetrieveError - When the API returns an error
The library maps API error codes to specific exception types, making error handling straightforward and explicit.
FindError - Raised when address search failsRetrieveError - Raised when address retrieval failsBoth exceptions automatically map error codes to specific exception classes (e.g., InvalidSearchTermError, AccountSuspendedError, UnknownKeyError) for granular error handling.
Licensed under the GNU General Public License v3.0 (GPL-3.0). See LICENSE for details.
Pull requests are welcome. For major changes, please open an issue first to discuss what you'd like to change.
Found a bug or have a question? Open an issue on GitHub.
Author: Darian Elwood (dellwood546@gmail.com)
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.0.3 | 20 Jan 2026 | 1 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 19:21 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:6540b684e288bfb12eb4962c9e7d026ac93d19536c80ec8fd923fed64f1be6f7