Setup
Install addresszen from PyPI, create one AddressZen client with your API key and reuse it for every request.
pip install addresszenimport os
from addresszen import AddressZen
with AddressZen(os.environ["ADDRESSZEN_API_KEY"]) as client:
hits = client.find_address(query="100 Queen St W, Toronto", context="CAN").hitsThe client keeps a pool of HTTP connections open. Use it as a context manager, or call close() when your process finishes.
Client options
| Argument | Default | Purpose |
|---|---|---|
api_key | required | Your API key, beginning ak_ |
timeout | 10.0 | Seconds to wait for each request |
base_url | https://api.addresszen.com/v1 | API root. Change it only to point at a test server |
transport | None | An HTTPX transport, such as httpx.MockTransport in tests |
Every argument after api_key is keyword-only. The SDK sends the API key as Authorization: Bearer ak_... on each lookup, never in the URL.
Management Key
To read or change your account: key details, usage, logs, licensees and configs. A Management Key begins uk_. Pass it to each of those methods as user_token. The SDK sends it as Authorization: Bearer uk_... in place of the API key, never in the URL.
A Management Key controls your account. Keep it in a secret store on your server, never in a browser or mobile app.
Async code
The client is synchronous. From an async application, run calls in a worker thread with asyncio.to_thread.
User-Agent
Every request carries User-Agent: addresszen-python-sdk/<version> python/<python version>, such as addresszen-python-sdk/0.2.1 python/3.12.3. The header holds no credentials or address data.