postcodeapi
postcodeapi is an unofficial Python wrapper around the Postcode API V2.
Installation and usage
Installation
postcodeapi can be installed by running pip install postcodeapi.
Usage
Here is an example of how to use the API client. First you initialize a client with your API key, after that you use one of the four getter methods to fetch the data you need. They all return the actual JSON response converted to a Python dictionary.
# Import the PostcodeAPIClient
from postcodeapi.client import PostcodeAPIClient
# Initialize a client with your API key
client = PostcodeAPIClient(api_key="YOUR_API_KEY")
# Fetch a list of addresses (for a given postal_code and number)
# The postal_code and number parameters are optional
# The number parameter only works together with postal_code
data = client.get_all_addresses(postal_code="5038EA", number=19)
addresses = data["results"] # List of addresses
next_id = data["next"] # Next ID to search from (used for pagination)
# Fetch a single address
address = client.get_address(address_id="0855200000046355")
# Fetch a list of postal codes (within a specific area)
# The area parameter is optional
data = client.get_all_postal_codes(area="5038")
postal_codes = data["results"] # List of postal codes
next_postal_code = data["next"] # Next postal code to search from (used for pagination)
# Fetch a single postal code
postal_code = client.get_postal_code("5038EA")
Exceptions
There are 5 exceptions that can occur:
NoAccessException, which occurs when the current account does not have the required privileges to perform the action;
ResourceNotFoundException, which occurs when the returned status_code is 404. Limited to the get_address and get_postal_code methods;
HouseNumberRequiresPostalCodeException, which occurs when a house_number is given but not a postal_code. Limited to the get_all_addresses method;
InvalidPostalCodeException, which occurs when an invalid postal code is given;
LimitExceededException, which occurs when there are too many network requests or the limit has been exceeded
Documentation
For more information about the data that is returned, please refer to the official API documentation. It is written in Dutch.
Running tests
To run the tests, make sure you install the dev dependencies by running pipenv install --dev, and then run
Metadata
Release files for postcodeapi 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| postcodeapi-1.2.1.tar.gz | 4.7 kB | Without provenance | Details for postcodeapi-1.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| postcodeapi-1.2.1-py3-none-any.whl | Python 3 | none | any | Details for postcodeapi-1.2.1-py3-none-any.whl |
Total release size: 9.7 kB
Release files / postcodeapi-1.2.1.tar.gz
| Download URL | postcodeapi-1.2.1.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e59a96d83b00b6987f6a64e32b0b95491723a0314632f9d3ee905a599aa4dca5
|
|
BLAKE2b-256 checksum How to use checksums |
6d1f5a253589296796c84c6be2ff1dabcd6817cf6a8cdc58822a0517bd70ec77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.7
|
Release files / postcodeapi-1.2.1-py3-none-any.whl
| Download URL | postcodeapi-1.2.1-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eaedce8481c2373a8f4142b4fd96898933c5158c70496f68f30392493148ff0d
|
|
BLAKE2b-256 checksum How to use checksums |
536131bebf999737f7116b93e3df6e47e7d2d3221f45956f047dab5ade3b7871
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.7
|
Security for postcodeapi 1.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.