This is a PHP client for ApiCheck endpoints. ApiCheck helps you validate customer data.
Currently supported countries: The Netherlands, Belgium, and Luxembourg.
- Register an account at ApiCheck Dashboard and select the appropriate subscription type.
- Create a new API key.
Use composer to install this package
$ composer require api-check/php-client:^1.0
{
"require": {
"api-check/php-client": "^1.0"
}
}
The first step is to set your API key (optionally also load autoload.php):
The lookup API is currently only supported for NL and LU. See: Lookup API documentation
use ApiCheck\Api\ApiClient;
require "./vendor/autoload.php";
$apicheckClient = new ApiClient();
$apicheckClient->setApiKey("YOUR_API_KEY");
Use the Lookup API
$address = $apicheckClient->lookup('nl', ['postalcode' => '2513AA', 'number' => 1]);
// Do something with the result:
print("🥳 Yay! We have a result: \n $address->street $address->number \n $address->postalcode $address->city \n {$address->Country->name}");
The search API is currently supported for NL, BE, LU and FR. See: Search API documentation
$results = $apicheckClient->search('be', 'city', ['name' => 'Namur']);
This will return an array with the search results
The ApiCheck client uses custom Exceptions to handle failure responses:
use ApiCheck\Api\ApiClient;
use ApiCheck\Api\Exceptions\NotFoundException;
use ApiCheck\Api\Exceptions\ValidationException;
use ApiCheck\Api\Exceptions\UnsupportedCountryException;
try {
$address = $apicheckClient->lookup('nl', ['postalcode' => '2513AA', 'number' => 1]);
} catch (NotFoundException $e) {
// No results have been found using the supplied data
} catch (ValidationException $e) {
// One of the submitted fields is not valid or set
} catch (UnsupportedCountryException $e) {
// The given country-code is not supported
}
More examples can be found in the examples directory.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Contact: www.apicheck.nl — support@apicheck.nl