Download the PHP package label84/php-nederland-postcode without Composer
On this page you can find all versions of the php package label84/php-nederland-postcode. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download label84/php-nederland-postcode
More information about label84/php-nederland-postcode
Files in label84/php-nederland-postcode
Package php-nederland-postcode
Short Description Integrate Dutch address validations into your PHP application using the Nederland Postcode API.
License MIT
Informations about the package php-nederland-postcode
Nederland Postcode PHP
Nederland Postcode PHP makes it easy to integrate Dutch address validations into your PHP application using the Nederland Postcode API.
Register for free to obtain a test API key at nederlandpostcode.nl to get started.
- Requirements
- Installation
- Usage
- Address Endpoint
- Single Address
- Multiple Addresses
- Energy Label Endpoint
- Quota Endpoint
- Error Handling
Requirements
- PHP 8.2+
Installation
Install the package via Composer:
Usage
Address Endpoint
The address endpoint allows you to fetch address information from the Nederland Postcode API.
You can search addresses using either the find method for a single address or the list method for multiple addresses. The find method will throw an exception if no address is found or if multiple addresses are found for the given postcode and house number (ie. when the house number has multiple additions like A, B, C, etc.).
The following optional attributes can be requested to be included in the response:
coordinates: Includes latitude and longitude of the address.district: Includes the official and name of the district that the address belongs to.function: Includes the function of the address (e.g. residential, commercial, healthcare, etc.).location_status: Includes the location status of the address (e.g. active, in development, etc.).property_status: Includes the property status of the address (e.g. in use, under construction, etc.).surface_area: Includes the surface area of the property in square meters.construction_year: Includes the construction year of the property.
Single Address
To fetch a single address for a given postcode and house number, you can use the find method.
The postcode and number parameters are required. The addition parameter is optional.
This will return an Address object like this:
When no address is found for the given postcode and number, an AddressNotFoundException is thrown. If multiple addresses are found, a MultipleAddressesFoundException is thrown.
Multiple Addresses
To fetch multiple addresses for a given postcode and house number, you can use the list method.
The postcode and number parameters are required. The addition parameter is optional.
This will return an AddressCollection like this:
Energy Label Endpoint
The energy label endpoint allows you to fetch energy label information for a given postcode and house number (with optional addition).
This will return an EnergyLabelCollection like this:
Quota Endpoint
The quota endpoint allows you to check your current API usage and limits. This endpoint does not increment your usage count.
[!NOTE] Values may lag behind the actual usage. They're cached for up to five minutes, so the
usedandlimitnumbers might not be fully up-to-date.
This will return an Quota object like this:
Error Handling
The package throws a NederlandPostcodeException for any errors encountered during the API request. You can catch this exception to handle errors gracefully:
When calling the find method, if no address is found, an AddressNotFoundException is thrown. If multiple addresses are found, a MultipleAddressesFoundException is thrown.
When a network or HTTP error occurs during the API request, a NederlandPostcodeRequestException is thrown, which wraps the original RequestException.