API

JSON Request

Request url
https://controleerbtwnummer.eu/api/validate/BE0123456789.json
JSON response not valid
object(stdClass) {
    valid => false
    countryCode => 'BE'
    vatNumber => '0123456789'
    name => null
    address => object(stdClass) {
        street => null
        number => null
        zip_code => null
        city => null
        country => 'België'
    }
    strAddress => null
}
JSON response valid
object(stdClass) {
    valid => true
    countryCode => 'BE'
    vatNumber => '0684579082'
    name => 'BVBA MILJAAR'
    address => object(stdClass) {
        street => 'VICHTESTEENWEG'
        number => '53'
        zip_code => '8540'
        city => 'DEERLIJK'
        country => 'België'
    }
    strAddress => 'VICHTESTEENWEG 53\n8540 DEERLIJK'
}

PHP

$vat_number = 'BE 0123 456 789';
$vat_number = str_replace(array(' ', '.', '-', ',', ', '), '', trim($vat_number));

$contents = @file_get_contents('https://controleerbtwnummer.eu/api/validate/'.$vat_number.'.json');
if($contents === false) {
    throw new Exception('service unavailable');

else {
    $res = json_decode($contents);

    if($res->valid) {
        //vat number is valid
    }
    else {
        //vat number is not valid
    }
    var_dump($res);
}