### Implement Postcode API v3 Lookup with API Key Source: https://www.postcodeapi.nu/docs/index Shows how to make a GET request to the Postcode API v3 to retrieve address details based on postcode and house number. It includes an example of adding the API key in the 'X-Api-Key' header. ```HTTP GET https://api.postcodeapi.nu/v3/lookup/6545CA/29 HTTP/1.1 X-Api-Key: 3a696aafc86c408d936d ``` -------------------------------- ### Implement Postcode API v3 Lookup using cURL Source: https://www.postcodeapi.nu/docs/index Provides a cURL command example for fetching address data from the Postcode API v3. This method also requires specifying the API key via the 'X-Api-Key' header. ```Shell curl -H "X-Api-Key: 3a696aafc86c408d936d" "https://api.postcodeapi.nu/v3/lookup/6545CA/29" ``` -------------------------------- ### Example HAL+JSON Response for Addresses Source: https://www.postcodeapi.nu/docs/v2 This is a sample response in HAL+JSON format for a successful address query. It includes embedded address details and hypermedia links for navigation, such as 'self' and 'next' links for pagination. ```json { "_embedded": { "addresses": [ { "id": "0268200000075156", "street": "Binderskampweg", "number": 29, "letter": "U", "addition": "31", "postcode": "6545CA", "surface": 144, "nen5825": { "street": "BINDERSKAMPWEG", "postcode": "6545 CA" }, "city": { "id": "1", "label": "Nijmegen" }, "municipality": { "id": "3030", "label": "Nijmegen" }, "province": { "id": "1", "label": "Gelderland" }, "geo": { "center": { "wgs84": { "type": "Point", "coordinates": [ 6.861053257304809, 53.32271304611565 ], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } } }, "rd": { "type": "Point", "coordinates": [ 253207, 593924 ], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::28992" } } } } }, "type": "Verblijfsobject", "purpose": "woonfunctie", "year": 1987, "_links": { "self": { "href": "https://api.postcodeapi.nu/v2/addresses/0268200000075156/" } } } ] }, "_links": { "self": { "href": "https://api.postcodeapi.nu/v2/addresses/" }, "next": { "href": "https://api.postcodeapi.nu/v2/addresses/?from=0268200000075156" } } } ``` -------------------------------- ### GET /addresses/{id}/ Source: https://www.postcodeapi.nu/docs/v2 Retrieves detailed information about a specific address using its unique identifier. ```APIDOC ## GET /addresses/{id}/ ### Description Retrieves detailed information about a specific address using its unique identifier. ### Method GET ### Endpoint https://api.postcodeapi.nu/v2/addresses/{id}/ ### Parameters #### Path Parameters - **id** (string) - Required - Identifier of the address, equal to the government standard BAG. ### Response #### Success Response (200) - **id** (string) - The unique identifier of the address. - **street** (string) - The name of the street. - **number** (integer) - The street number. - **letter** (string) - The street letter, if applicable. - **addition** (string) - Additional street number information, if applicable. - **postcode** (string) - The postcode of the address. - **surface** (integer) - The surface area of the property. - **nen5825** (object) - NEN5825 compliant street and postcode information. - **street** (string) - NEN5825 street name. - **postcode** (string) - NEN5825 postcode. - **city** (object) - Information about the city. - **id** (string) - The city identifier. - **label** (string) - The name of the city. - **municipality** (object) - Information about the municipality. - **id** (string) - The municipality identifier. - **label** (string) - The name of the municipality. - **province** (object) - Information about the province. - **id** (string) - The province identifier. - **label** (string) - The name of the province. - **geo** (object) - Geographic coordinates. - **center** (object) - Center point coordinates. - **wgs84** (object) - WGS84 coordinates. - **type** (string) - Type of GeoJSON object. - **coordinates** (array) - Longitude and latitude. - **crs** (object) - Coordinate Reference System. - **rd** (object) - RD coordinates. - **type** (string) - Type of GeoJSON object. - **coordinates** (array) - X and Y coordinates. - **crs** (object) - Coordinate Reference System. - **exterior** (object) - Exterior boundary coordinates. - **wgs84** (object) - WGS84 boundary coordinates. - **type** (string) - Type of GeoJSON object. - **coordinates** (array) - Polygon coordinates. - **crs** (object) - Coordinate Reference System. - **type** (string) - The type of address object. - **purpose** (string) - The purpose of the address (e.g., 'woonfunctie'). - **year** (integer) - The year the property was built. - **_links** (object) - Links to related resources. - **self** (object) - Link to the current resource. #### Response Example ```json { "id": "0268200000075156", "street": "Binderskampweg", "number": 29, "letter": "U", "addition": "31", "postcode": "6545CA", "surface": 144, "nen5825": { "street": "BINDERSKAMPWEG", "postcode": "6545 CA" }, "city": { "id": "1", "label": "Nijmegen" }, "municipality": { "id": "3030", "label": "Nijmegen" }, "province": { "id": "1", "label": "Gelderland" }, "geo": { "center": { "wgs84": { "type": "Point", "coordinates": [ 6.861053257304809, 53.32271304611565 ], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } } }, "rd": { "type": "Point", "coordinates": [ 253207, 593924 ], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::28992" } } } }, "exterior": { "wgs84": { "type": "Polygon", "coordinates": [ [ [ 6.22650146484375, 52.300081389496114 ], [ 6.22650146484375, 52.43759500093112 ], [ 6.42425537109375, 52.43759500093112 ], [ 6.42425537109375, 52.300081389496114 ], [ 6.22650146484375, 52.300081389496114 ] ] ], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } } } } }, "type": "Verblijfsobject", "purpose": "woonfunctie", "year": 1987, "_links": { "self": { "href": "https://api.postcodeapi.nu/v2/addresses/0268200000075156/" } } } ``` ``` -------------------------------- ### Authenticate and Request Addresses with PHP Source: https://www.postcodeapi.nu/docs/v2 This PHP code example shows how to authenticate and make a request to the Postcode API to fetch address data. It illustrates setting the 'X-Api-Key' header and executing the request using cURL, with options for handling SSL verification and decoding the JSON response. ```php // De headers worden altijd meegestuurd als array $headers = array(); $headers[] = 'X-Api-Key: a0B1c2D34D5c6b7a8'; // De URL naar de API call $url = 'https://api.postcodeapi.nu/v2/addresses/?postcode=1234AB'; $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); // Indien de server geen TLS ondersteunt kun je met // onderstaande optie een onveilige verbinding forceren. // Meestal is dit probleem te herkennen aan een lege response. // curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // De ruwe JSON response $response = curl_exec($curl); // Gebruik json_decode() om de response naar een PHP array te converteren $data = json_decode($response); curl_close($curl); ``` -------------------------------- ### GET /v2/addresses/ Source: https://www.postcodeapi.nu/docs/v2 Retrieves a paginated list of all addresses in the Netherlands. It can be filtered by postcode and optionally by house number. ```APIDOC ## GET /v2/addresses/ ### Description Retrieves a paginated list of all addresses in the Netherlands. This endpoint can be filtered by postcode and house number. Responses include HAL hypermedia links for navigation. ### Method GET ### Endpoint https://api.postcodeapi.nu/v2/addresses/ ### Parameters #### Query Parameters - **postcode** (string) - Required - Filters results by postcode in P6 format (e.g., `1234AB`). - **number** (integer) - Optional - Filters results by house number. Only works in combination with the `postcode` parameter. ### Authentication Requires an `X-Api-Key` in the request header. ### Request Example ```bash curl -H "X-Api-Key: YOUR_API_KEY" "https://api.postcodeapi.nu/v2/addresses/?postcode=1234AB&number=1" ``` ### Responses #### Success Response (200) - **_embedded** (object) - Contains the list of addresses. - **addresses** (array) - Array of address objects. - **id** (string) - Unique identifier for the address. - **street** (string) - Street name. - **number** (integer) - House number. - **letter** (string) - House letter, if applicable. - **addition** (string) - Addition to the house number, if applicable. - **postcode** (string) - Postcode. - **surface** (number) - Surface area. - **nen5825** (object) - NEN5825 standardized address information. - **city** (object) - City information. - **municipality** (object) - Municipality information. - **province** (object) - Province information. - **geo** (object) - Geographical coordinates (WGS84 and RD). - **type** (string) - Type of address (e.g., 'Verblijfsobject'). - **purpose** (string) - Purpose of the address (e.g., 'woonfunctie'). - **year** (integer) - Year of construction. - **_links** (object) - Hypermedia links. - **_links** (object) - Hypermedia links for pagination. #### Response Example (200 OK) ```json { "_embedded": { "addresses": [ { "id": "0268200000075156", "street": "Binderskampweg", "number": 29, "letter": "U", "addition": "31", "postcode": "6545CA", "surface": 144, "nen5825": { "street": "BINDERSKAMPWEG", "postcode": "6545 CA" }, "city": { "id": "1", "label": "Nijmegen" }, "municipality": { "id": "3030", "label": "Nijmegen" }, "province": { "id": "1", "label": "Gelderland" }, "geo": { "center": { "wgs84": { "type": "Point", "coordinates": [ 6.861053257304809, 53.32271304611565 ], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } } }, "rd": { "type": "Point", "coordinates": [ 253207, 593924 ], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::28992" } } } } }, "type": "Verblijfsobject", "purpose": "woonfunctie", "year": 1987, "_links": { "self": { "href": "https://api.postcodeapi.nu/v2/addresses/0268200000075156/" } } } ] }, "_links": { "self": { "href": "https://api.postcodeapi.nu/v2/addresses/" }, "next": { "href": "https://api.postcodeapi.nu/v2/addresses/?from=0268200000075156" } } } ``` #### Error Responses - **400 Bad request**: Invalid query parameters provided. - **401 Unauthorized**: API key is missing or invalid. - **403 Forbidden**: Client does not have permission to perform this action. - **429 Too Many Requests**: Rate limit exceeded (for free accounts). ``` -------------------------------- ### GET /postcodes/{postcode}/ Source: https://www.postcodeapi.nu/docs/v2 Retrieves information about a single, specific postcode. ```APIDOC ## GET /postcodes/{postcode}/ ### Description Retrieves information about a single, specific postcode. ### Method GET ### Endpoint https://api.postcodeapi.nu/v2/postcodes/{postcode}/ ### Parameters #### Path Parameters - **postcode** (string) - Required - The postcode in P6 format. ### Response #### Success Response (200) - **postcode** (string) - The requested postcode. - **city** (object) - Information about the city. - **id** (string) - The city identifier. - **label** (string) - The name of the city. - **municipality** (object) - Information about the municipality. - **id** (string) - The municipality identifier. - **label** (string) - The name of the municipality. - **province** (object) - Information about the province. - **id** (string) - The province identifier. - **label** (string) - The name of the province. - **streets** (string) - A JSON string representing an array of street names associated with the postcode. - **nen5825** (object) - NEN5825 compliant street and postcode information. - **streets** (string) - A JSON string representing NEN5825 street names. - **postcode** (string) - NEN5825 postcode. - **geo** (object) - Geographic coordinates. - **center** (object) - Center point coordinates. - **wgs84** (object) - WGS84 coordinates. - **type** (string) - Type of GeoJSON object. - **coordinates** (array) - Longitude and latitude. - **crs** (object) - Coordinate Reference System. #### Response Example (The response structure for a single postcode is similar to an item within the '_embedded.postcodes' array from the 'GET /postcodes/' endpoint, but without the '_links' object.) ``` -------------------------------- ### GET /postcodes/ Source: https://www.postcodeapi.nu/docs/v2 Retrieves a paginated list of all postcodes in the Netherlands. Supports filtering by postcode area. ```APIDOC ## GET /postcodes/ ### Description Retrieves a paginated list of all postcodes in the Netherlands. Supports filtering by postcode area. ### Method GET ### Endpoint https://api.postcodeapi.nu/v2/postcodes/ ### Parameters #### Query Parameters - **postcodeArea** (string) - Optional - Filters the results by postcode area in P4 format (only the digits of a postcode). ### Response #### Success Response (200) - **_embedded** (object) - Contains the list of postcodes. - **postcodes** (array) - An array of postcode objects. - **postcode** (string) - The postcode. - **city** (object) - Information about the city. - **id** (string) - The city identifier. - **label** (string) - The name of the city. - **municipality** (object) - Information about the municipality. - **id** (string) - The municipality identifier. - **label** (string) - The name of the municipality. - **province** (object) - Information about the province. - **id** (string) - The province identifier. - **label** (string) - The name of the province. - **streets** (string) - A JSON string representing an array of street names. - **nen5825** (object) - NEN5825 compliant street and postcode information. - **streets** (string) - A JSON string representing NEN5825 street names. - **postcode** (string) - NEN5825 postcode. - **geo** (object) - Geographic coordinates. - **center** (object) - Center point coordinates. - **wgs84** (object) - WGS84 coordinates. - **type** (string) - Type of GeoJSON object. - **coordinates** (array) - Longitude and latitude. - **crs** (object) - Coordinate Reference System. - **_links** (object) - Links to related resources. - **self** (object) - Link to the current postcode resource. - **_links** (object) - Links to pagination resources. - **self** (object) - Link to the current page. - **next** (object) - Link to the next page of results. #### Response Example ```json { "_embedded": { "postcodes": [ { "postcode": "6545CA", "city": { "id": "1", "label": "Nijmegen" }, "municipality": { "id": "3030", "label": "Nijmegen" }, "province": { "id": "1", "label": "Gelderland" }, "streets": "[\"Binderskampweg\", \"Kronenburgersingel\"]", "nen5825": { "streets": "[\"BINDERSKAMPWEG\", \"KRONENBURGERSINGEL\"]", "postcode": "6545 CA" }, "geo": { "center": { "wgs84": { "type": "Point", "coordinates": [ 6.861053257304809, 53.32271304611565 ], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } } } } }, "_links": { "self": { "href": "https://api.postcodeapi.nu/v2/postcodes/6545CA/" } } } ] }, "_links": { "self": { "href": "https://api.postcodeapi.nu/v2/postcodes/" }, "next": { "href": "https://api.postcodeapi.nu/v2/postcodes/?from=6545CA" } } } ``` ``` -------------------------------- ### Postcode API v3 JSON Response Example Source: https://www.postcodeapi.nu/docs/index Illustrates the typical JSON response format received from the Postcode API v3 after a successful lookup. It includes details like postcode, number, street, city, municipality, province, and geographical coordinates. ```JSON HTTP/1.1 200 OK Content-Type: application/json { "postcode": "6545CA", "number": 29, "street": "Binderskampweg", "city": "Nijmegen", "municipality": "Nijmegen", "province": "Gelderland", "location": { "type": "Point", "coordinates": [ 5.858910083770752, 51.84376540294041 ] } } ``` -------------------------------- ### Retrieve All Postcodes - JSON Example Source: https://www.postcodeapi.nu/docs/v2 This snippet shows the JSON structure for retrieving a list of postcodes. It includes embedded postcode data and links for pagination. The 'streets' field may contain a JSON string representation of an array. ```json { "_embedded": { "postcodes": [ { "postcode": "6545CA", "city": { "id": "1", "label": "Nijmegen" }, "municipality": { "id": "3030", "label": "Nijmegen" }, "province": { "id": "1", "label": "Gelderland" }, "streets": "[\"Binderskampweg\", \"Kronenburgersingel\"]", "nen5825": { "streets": "[\"BINDERSKAMPWEG\", \"KRONENBURGERSINGEL\"]", "postcode": "6545 CA" }, "geo": { "center": { "wgs84": { "type": "Point", "coordinates": [ 6.861053257304809, 53.32271304611565 ], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } } } } }, "_links": { "self": { "href": "https://api.postcodeapi.nu/v2/postcodes/6545CA/" } } } ] }, "_links": { "self": { "href": "https://api.postcodeapi.nu/v2/postcodes/" }, "next": { "href": "https://api.postcodeapi.nu/v2/postcodes/?from=6545CA" } } } ``` -------------------------------- ### Retrieve Address by ID - JSON Example Source: https://www.postcodeapi.nu/docs/v2 This snippet demonstrates the JSON response structure when retrieving address details using a specific ID. The response includes various address components like street, number, city, and geographical coordinates. ```json { "id": "0268200000075156", "street": "Binderskampweg", "number": 29, "letter": "U", "addition": "31", "postcode": "6545CA", "surface": 144, "nen5825": { "street": "BINDERSKAMPWEG", "postcode": "6545 CA" }, "city": { "id": "1", "label": "Nijmegen" }, "municipality": { "id": "3030", "label": "Nijmegen" }, "province": { "id": "1", "label": "Gelderland" }, "geo": { "center": { "wgs84": { "type": "Point", "coordinates": [ 6.861053257304809, 53.32271304611565 ], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } } }, "rd": { "type": "Point", "coordinates": [ 253207, 593924 ], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::28992" } } } }, "exterior": { "wgs84": { "type": "Polygon", "coordinates": [ [ [ 6.22650146484375, 52.300081389496114 ], [ 6.22650146484375, 52.43759500093112 ], [ 6.42425537109375, 52.43759500093112 ], [ 6.42425537109375, 52.300081389496114 ], [ 6.22650146484375, 52.300081389496114 ] ] ], "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } } } } }, "type": "Verblijfsobject", "purpose": "woonfunctie", "year": 1987, "_links": { "self": { "href": "https://api.postcodeapi.nu/v2/addresses/0268200000075156/" } } } ``` -------------------------------- ### Test Sandbox Postcode API v3 Lookup Source: https://www.postcodeapi.nu/docs/index Demonstrates how to test the sandbox environment of the Postcode API v3 using provided fake postcode and house number combinations. This helps verify API functionality before using the production environment. ```HTTP GET https://sandbox.postcodeapi.nu/v3/lookup/6545CA/29 HTTP/1.1 ``` -------------------------------- ### Postcode API v3 Lookup (Sandbox) Source: https://www.postcodeapi.nu/docs/index The sandbox environment allows testing the lookup function of Postcode API v3 without using real data. Use the provided fake postcode/house number combinations to test its functionality. To access production, you need to upgrade to a paid key and change the URL. ```APIDOC ## GET /v3/lookup (Sandbox) ### Description Performs a lookup using postcode and house number in the sandbox environment. ### Method GET ### Endpoint `https://sandbox.postcodeapi.nu/v3/lookup/{postcode}/{number}` ### Parameters #### Path Parameters - **postcode** (string) - Required - The postcode to look up. - **number** (string) - Required - The house number to look up. ### Request Example `GET https://sandbox.postcodeapi.nu/v3/lookup/6545CA/29` ### Response #### Success Response (200) - **postcode** (string) - The postcode. - **number** (string) - The house number. - **street** (string) - The street name. - **city** (string) - The city name. - **municipality** (string) - The municipality name. - **province** (string) - The province name. - **location** (object) - Geographic coordinates. - **type** (string) - The type of location (e.g., 'Point'). - **coordinates** (array) - An array containing longitude and latitude. #### Response Example ```json { "postcode": "6545CA", "number": 29, "street": "Waldeck Pyrmontsingel", "city": "Nijmegen", "municipality": "Nijmegen", "province": "Gelderland", "location": { "type": "Point", "coordinates": [ 5.858910083770752, 51.84376540294041 ] } } ``` #### Error Responses - **400 Bad Request**: Invalid postcode or number format. - **404 Not Found**: Address not found. ``` -------------------------------- ### Postcode API v3 Lookup (Production) Source: https://www.postcodeapi.nu/docs/index Implement Postcode API v3 to automatically fill in street and city based on postcode and house number. This endpoint requires an API key for authentication. ```APIDOC ## GET /v3/lookup (Production) ### Description Performs a lookup using postcode and house number in the production environment. Requires an API key. ### Method GET ### Endpoint `https://api.postcodeapi.nu/v3/lookup/{postcode}/{number}` ### Parameters #### Path Parameters - **postcode** (string) - Required - The postcode to look up. Ensure spaces are removed. - **number** (string) - Required - The house number to look up. Ensure letters are removed if applicable. #### Headers - **X-Api-Key** (string) - Required - Your unique API key for authentication. ### Request Example ```http GET https://api.postcodeapi.nu/v3/lookup/6545CA/29 HTTP/1.1 X-Api-Key: YOUR_API_KEY ``` #### Curl Example ```bash curl -H "X-Api-Key: YOUR_API_KEY" "https://api.postcodeapi.nu/v3/lookup/6545CA/29" ``` ### Response #### Success Response (200) - **postcode** (string) - The postcode. - **number** (string) - The house number. - **street** (string) - The street name. - **city** (string) - The city name. - **municipality** (string) - The municipality name. - **province** (string) - The province name. - **location** (object) - Geographic coordinates. - **type** (string) - The type of location (e.g., 'Point'). - **coordinates** (array) - An array containing longitude and latitude. #### Response Example ```json { "postcode": "6545CA", "number": 29, "street": "Binderskampweg", "city": "Nijmegen", "municipality": "Nijmegen", "province": "Gelderland", "location": { "type": "Point", "coordinates": [ 5.858910083770752, 51.84376540294041 ] } } ``` **Note**: Do not send a Request Payload or Content-Type header as this is a GET operation. ``` -------------------------------- ### Authenticate and Request Addresses with cURL Source: https://www.postcodeapi.nu/docs/v2 This snippet demonstrates how to make a request to the Postcode API using cURL to retrieve addresses. It shows how to include the required 'X-Api-Key' header for authentication and specifies query parameters for postcode and number. ```shell curl -H "X-Api-Key: a0B1c2D34D5c6b7a8" "https://api.postcodeapi.nu/v2/addresses/?postcode=1234AB" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.