PHP code example of vladshut / postcode-api-client

1. Go to this page and download the library: Download vladshut/postcode-api-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vladshut / postcode-api-client example snippets


// Use the composer autoloader to load dependencies
n_api_key';
// In this example we made use of the Guzzle6 as HTTPClient in combination with an HTTPPlug compatible adapter.
$client = new \VS\PostcodeAPI\Client(
    new Http\Adapter\Guzzle6\Client(
        new GuzzleHttp\Client([
            'headers' => [
                'X-Api-Key' => $apiKey
            ]
        ])
    )
);

// call endpoints
$response = $client->getAddresses('5041EB', 21);
$response = $client->getAddress('0855200000061001');
$response = $client->getPostcode('5041EB');

// Note that this call is only available with a premium account
$response = $client->getPostcodes('51.566405', '5.077171');