A PHP client for the ApiCheck API. Validate addresses, search locations, and verify contact data with ease.
Version: 2.0.0
- Lookup API - Validate postal addresses (NL, LU)
- Search API - Search cities, streets, postal codes, and addresses across 18 European countries
- Verify API - Verify email addresses and phone numbers
- PHP 8.1 or higher
- Register an account at ApiCheck Dashboard
- Create an API key
Install via Composer:
composer require api-check/php-client:^2.0Or add to your composer.json:
{
"require": {
"api-check/php-client": "^2.0"
}
}use ApiCheck\Api\ApiClient;
require "./vendor/autoload.php";
$client = new ApiClient();
$client->setApiKey("YOUR_API_KEY");
// Optionally set a referer if your API key has allowed hosts configured
$client->setReferer("https://your-domain.com");Look up addresses by postal code and house number. Currently supported for NL and LU.
$address = $client->lookup('nl', [
'postalcode' => '2513AA',
'number' => 1
]);
print("{$address->street} {$address->number}\n");
print("{$address->postalcode} {$address->city}\n");
print("{$address->Country->name}");$address = $client->lookup('nl', [
'postalcode' => '2513AA',
'number' => 1,
'fields' => ['street', 'city', 'latitude', 'longitude'], // Only return specific fields
'aliasses' => true, // Include subaddress relationships
'shortening' => true // Include streetShort field
]);Retrieve available number additions (like "A", "B", "1e") for a postal code:
$additions = $client->getNumberAdditions('nl', '2513AA', '1');
// Returns: ["1", "1A", "1B", ...]Search for cities, streets, postal codes, and addresses across 18 European countries.
// Search cities
$results = $client->search('be', 'city', ['name' => 'Namur']);
// Search streets
$results = $client->search('nl', 'street', ['name' => 'Hoofd']);
// Search postal codes
$results = $client->search('fr', 'postalcode', ['name' => '75001']);Search across all scopes at once:
$results = $client->globalSearch('nl', 'Hoofdf', [
'limit' => 10
]);Search localities (deelgemeenten) and municipalities (gemeenten):
// Search localities
$localities = $client->searchLocality('be', 'Gontrode');
// Search municipalities
$municipalities = $client->searchMunicipality('be', 'Gent');Resolve a full address using IDs from previous searches:
$address = $client->searchAddress('be', [
'street_id' => 12345,
'number' => '10',
'postalcode_id' => 67890
]);Retrieve the live list of supported countries:
$countries = $client->getSupportedSearchCountries();Verify email addresses and phone numbers.
$result = $client->verifyEmail('user@example.com');
// Returns:
// - disposable_email: bool
// - greylisted: bool
// - status: "valid" | "invalid" | "unknown"
if ($result->status === 'valid' && !$result->disposable_email) {
print("Email is valid and not disposable");
}$result = $client->verifyPhone('+31612345678');
// Returns:
// - valid: bool
// - country_code: string (e.g., "NL")
// - international_formatted: string
// - number_type: string (e.g., "mobile")The client uses specific exceptions for different error scenarios:
use ApiCheck\Api\ApiClient;
use ApiCheck\Api\Exceptions\NotFoundException;
use ApiCheck\Api\Exceptions\ValidationException;
use ApiCheck\Api\Exceptions\UnsupportedCountryException;
use ApiCheck\Api\Exceptions\UnauthorizedException;
use ApiCheck\Api\Exceptions\ApiKeyInvalidException;
use ApiCheck\Api\Exceptions\NoExactMatchException;
try {
$address = $client->lookup('nl', ['postalcode' => '2513AA', 'number' => 1]);
} catch (NotFoundException $e) {
// No results found
} catch (ValidationException $e) {
// Invalid or missing fields
} catch (UnsupportedCountryException $e) {
// Country not supported for this operation
} catch (UnauthorizedException $e) {
// Invalid or missing API key
} catch (NoExactMatchException $e) {
// No exact match found (Search API)
} catch (ApiException $e) {
// General API error
}ApiException- Base exception for all API errorsAccessDeniedException- Access deniedApiKeyExhaustedException- API key quota exceededApiKeyHeaderException- API key header missingApiKeyInvalidException- Invalid API keyBadRequestException- Bad request (400)HostNotAllowedException- Host not allowed for this API keyInternalServerErrorException- Server error (500)NoExactMatchException- No exact match foundNotFoundException- Resource not found (404)PageNotFoundException- Page not foundUnauthorizedException- Unauthorized (401)UnprocessableEntityException- Unprocessable entity (422)UnsupportedCountryException- Country not supportedValidationException- Validation failed
More examples can be found in the examples/ directory:
- Lookup examples - Basic lookup, number additions, options
- Search examples - Basic search, global search, Belgium-specific, address resolution
- Verify examples - Email and phone verification
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.
composer testContact: www.apicheck.nl — support@apicheck.nl