1. Go to this page and download the library: Download aade/afm-lookup 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/ */
aade / afm-lookup example snippets
use Aade\AfmLookup\AadeClient;
$client = new AadeClient('your_username', 'your_password');
$response = $client->getVatInfo('094014201');
if ($response->success) {
echo $response->basic->name; // Business name
echo $response->basic->afm; // VAT number
echo $response->basic->isActive; // true/false
}
use Aade\AfmLookup\AadeClient;
$client = new AadeClient('your_username', 'your_password');
use Aade\AfmLookup\AadeClient;
// Static method - no API call
if (AadeClient::validateAfm('094014201')) {
// Valid format (9 digits, correct check digit)
}
// Invalid examples:
AadeClient::validateAfm('12345678'); // false - only 8 digits
AadeClient::validateAfm('000000000'); // false - all zeros
AadeClient::validateAfm('094014202'); // false - wrong check digit
use DateTimeImmutable;
// Get info as of January 15, 2023
$date = new DateTimeImmutable('2023-01-15');
$response = $client->getVatInfo('094014201', $date);
$response = $client->getVatInfo('094014201');
// Get main activity
$main = $response->getMainActivity();
if ($main !== null) {
echo $main->code; // "35.11"
echo $main->description; // "Παραγωγή ηλεκτρικής ενέργειας"
}
// Iterate all activities
foreach ($response->firmActivities as $activity) {
echo $activity->code; // KAD code
echo $activity->description; // Activity description
echo $activity->kind; // 1 = main, 2+ = secondary
echo $activity->kindDescription; // "ΚΥΡΙΑ" or "ΔΕΥΤΕΡΕΥΟΥΣΑ"
echo $activity->isMainActivity(); // true/false
}
use Aade\AfmLookup\AadeClient;
use Aade\AfmLookup\Exception\InvalidAfmException;
use Aade\AfmLookup\Exception\AuthenticationException;
use Aade\AfmLookup\Exception\RateLimitException;
use Aade\AfmLookup\Exception\SoapException;
use Aade\AfmLookup\Exception\AadeException;
try {
$response = $client->getVatInfo('094014201');
} catch (InvalidAfmException $e) {
// AFM format is invalid (checked locally before API call)
} catch (AuthenticationException $e) {
// Wrong username/password or account not authorized
} catch (RateLimitException $e) {
// Daily call limit exceeded
} catch (SoapException $e) {
// Network error or SOAP fault
} catch (AadeException $e) {
// Other AADE service errors
$errorCode = $e->getErrorCode(); // ErrorCode enum or null
}
if ($e->getErrorCode()?->isAuthenticationError()) { /* ... */ }
if ($e->getErrorCode()?->isRateLimitError()) { /* ... */ }
if ($e->getErrorCode()?->isNotFoundError()) { /* ... */ }
if ($e->getErrorCode()?->isBlockedError()) { /* ... */ }
public function __construct(
string $username,
string $password,
?string $callerAfm = null,
int $timeout = 30,
bool $verifySsl = true,
)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.