This small API is intended as a way to check a postalcode, house number combination and return a status and the streetname if found.
Note
This solution is deprecated! As an alternative you could use bagconv which is an opensource alternative that uses official public data.
$ curl -s -k -X POST https://localhost:470/check -H 'application/json' --data '{"postcode":"1234ab", "house_number": 1, "country":"nl"}' | jq
{
"status": "success",
"response": {
"postcode": "1234AB",
"house_number": "1",
"street": "Kalverstraat",
"country": "NL"
}
}
Check if a postcode is valid and return the address if known. All data should be send with a JSON body and
the content type should be set to application/json
. The response will be output as JSON as well.
{
"postcode": "1234ab",
"house_number": "2",
"country": "nl"
}
Note: both postcode and house_number must be present to get a response. This is because dutch postal codes can have multiple streets (but with unique house numbers). If only the postcode is provided, the response will be empty.
Code | Description |
---|---|
200 | Success, response returned |
400 | Bad request, validation error |
404 | Postcode not found |
500 | Internal server error, retry later |
When a valid postcode has been submitted and address information is found:
{
"status": "success",
"response": {
"postcode": "1234AB",
"house_number": "1",
"street": "Kalverstraat",
"country": "NL"
}
}
When a valid postcode has been submitted but no address information could be found:
{
"status": "success"
}
When validation has failed:
{
"status": "error",
"errors": {
"country": [
"Country is ongeldig."
]
}
}
Data is currently not specified, but will be in the future. For now, the data is imported from a CSV file that can be found at: https://www.spikkl.nl/postcode-database/download/spikkl-postal-code-level-csv-demo.zip
To import:
$ php bin/console app:import <file.csv>