The VAT API provides a simple and reliable way to validate VAT numbers, retrieve VAT rates for EU countries, and calculate VAT amounts. The API is RESTful and returns data in JSON format.
Base URL: https://api.thevatapi.com
All API requests require an API key. You can include your API key as a query parameter in all requests:
https://api.thevatapi.com/endpoint?api_key=YOUR_API_KEY
API usage is limited based on your subscription plan. Each API call counts as one request against your monthly allowance. The API response includes your current usage information:
{
"success": true,
"message": "Success",
"code": 200,
"account": {
"monthly_allowance": 1000,
"current_month_allowance": 950,
"monthly_allowance_reset_date": "2025-06-01"
},
"data": { ... }
}
All API responses follow the same format:
{
"success": true|false,
"message": "Success or error message",
"code": 200, // HTTP status code
"account": { ... }, // Account information
"data": { ... } // Response data
}
The API uses standard HTTP status codes to indicate the success or failure of an API request:
Code | Description |
---|---|
200 | Success |
400 | Bad Request (general error) |
401 | Unauthorized (API key issues) |
404 | Not Found (resource not found) |
422 | Unprocessable Entity (validation error) |
429 | Too Many Requests (rate limit exceeded) |
500 | Internal Server Error (server-side issues) |
503 | Service Unavailable (external API issues) |
Validates a VAT number and returns company information if available.
GET /validate
Parameter | Type | Required | Description |
---|---|---|---|
api_key | string | Yes | Your API key |
vat_number | string | Yes | VAT number to validate (including country code, e.g., DE123456789) |
https://api.thevatapi.com/validate?api_key=YOUR_API_KEY&vat_number=LU26375245
{
"success": true,
"message": "Success",
"code": 200,
"account": {
"monthly_allowance": 1000,
"current_month_allowance": 950,
"monthly_allowance_reset_date": "2025-06-01"
},
"data": {
"valid": true,
"country": "Luxembourg",
"vat_number": "LU26375245",
"company_name": "AMAZON EUROPE CORE SARL",
"address": "38 AVENUE JOHN F KENNEDY, L-1855 LUXEMBOURG",
"cached": false
}
}
Retrieves VAT rates for a specific country.
GET /rates
Parameter | Type | Required | Description |
---|---|---|---|
api_key | string | Yes | Your API key |
country_code | string | Yes | Two-letter country code (e.g., DE for Germany) |
https://api.thevatapi.com/rates?api_key=YOUR_API_KEY&country_code=DE
{
"success": true,
"message": "Success",
"code": 200,
"account": {
"monthly_allowance": 1000,
"current_month_allowance": 949,
"monthly_allowance_reset_date": "2025-06-01"
},
"data": {
"DE": {
"country_name": "Germany",
"standard_rate": 19,
"reduced_rates": {
"reduced": 7
}
}
}
}
Retrieves VAT rates for all available countries.
GET /all_rates
Parameter | Type | Required | Description |
---|---|---|---|
api_key | string | Yes | Your API key |
https://api.thevatapi.com/all_rates?api_key=YOUR_API_KEY
{
"success": true,
"message": "Success",
"code": 200,
"account": {
"monthly_allowance": 1000,
"current_month_allowance": 948,
"monthly_allowance_reset_date": "2025-06-01"
},
"data": {
"AT": {
"country_name": "Austria",
"standard_rate": 20,
"reduced_rates": {
"reduced": 10,
"super-reduced": 13
}
},
"BE": {
"country_name": "Belgium",
"standard_rate": 21,
"reduced_rates": {
"reduced": 6,
"parking": 12
}
},
// Additional countries...
}
}
Calculates VAT amount based on a given amount, country, and rate type.
GET /calculate
Parameter | Type | Required | Description |
---|---|---|---|
api_key | string | Yes | Your API key |
amount | number | Yes | Amount to calculate VAT for (excluding VAT) |
country_code | string | Yes | Two-letter country code (e.g., DE for Germany) |
rate_type | string | No | VAT rate type (standard, reduced, etc.). Defaults to 'standard' |
https://api.thevatapi.com/calculate?api_key=YOUR_API_KEY&amount=10&country_code=DE&rate_type=standard
{
"success": true,
"message": "Success",
"code": 200,
"account": {
"monthly_allowance": 1000,
"current_month_allowance": 947,
"monthly_allowance_reset_date": "2025-06-01"
},
"data": {
"amount": 10,
"country_code": "DE",
"country_name": "Germany",
"rate_type": "standard",
"rate_name": "Standard Rate",
"rate_percentage": 19,
"vat_amount": 1.9,
"total_amount": 11.9
}
}
Here's how to use the API with PHP:
<?php
// Your API key
$apiKey = 'YOUR_API_KEY';
// Base URL
$baseUrl = 'https://api.thevatapi.com';
// Function to make API requests
function callApi($endpoint, $params = []) {
global $apiKey, $baseUrl;
// Add API key to parameters
$params['api_key'] = $apiKey;
// Build URL with query parameters
$url = $baseUrl . $endpoint . '?' . http_build_query($params);
// Initialize cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
// Execute request
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Check for errors
if (curl_errno($ch)) {
$error = curl_error($ch);
curl_close($ch);
return ['success' => false, 'message' => 'cURL error: ' . $error];
}
curl_close($ch);
// Parse JSON response
$result = json_decode($response, true);
return $result;
}
// Example: Validate VAT number
$vatNumber = 'LU26375245';
$validationResult = callApi('validate', ['vat_number' => $vatNumber]);
if ($validationResult['success']) {
echo "VAT number is " . ($validationResult['data']['valid'] ? 'valid' : 'invalid') . "\n";
if ($validationResult['data']['valid']) {
echo "Company: " . $validationResult['data']['company_name'] . "\n";
echo "Address: " . $validationResult['data']['address'] . "\n";
}
} else {
echo "Error: " . $validationResult['message'] . "\n";
}
// Example: Get VAT rates for Germany
$ratesResult = callApi('rates', ['country_code' => 'DE']);
if ($ratesResult['success']) {
echo "Standard rate: " . $ratesResult['data']['DE']['standard_rate'] . "%\n";
echo "Reduced rate: " . $ratesResult['data']['DE']['reduced_rates']['reduced'] . "%\n";
} else {
echo "Error: " . $ratesResult['message'] . "\n";
}
// Example: Calculate VAT
$calculateResult = callApi('calculate', [
'amount' => 100,
'country_code' => 'DE',
'rate_type' => 'standard'
]);
if ($calculateResult['success']) {
echo "Amount: €" . $calculateResult['data']['amount'] . "\n";
echo "VAT amount: €" . $calculateResult['data']['vat_amount'] . "\n";
echo "Total: €" . $calculateResult['data']['total_amount'] . "\n";
} else {
echo "Error: " . $calculateResult['message'] . "\n";
}
?>
Here's how to use the API with JavaScript:
// Your API key
const apiKey = 'YOUR_API_KEY';
// Base URL
const baseUrl = 'https://api.thevatapi.com';
// Function to make API requests
async function callApi(endpoint, params = {}) {
// Add API key to parameters
params.api_key = apiKey;
// Build URL with query parameters
const url = `${baseUrl}${endpoint}?${new URLSearchParams(params)}`;
try {
// Make request
const response = await fetch(url, {
method: 'GET',
headers: {
'Accept': 'application/json'
}
});
// Parse JSON response
const data = await response.json();
return data;
} catch (error) {
return {
success: false,
message: `Error: ${error.message}`
};
}
}
// Example: Validate VAT number
async function validateVat() {
const vatNumber = 'LU26375245';
const result = await callApi('validate', { vat_number: vatNumber });
if (result.success) {
console.log(`VAT number is ${result.data.valid ? 'valid' : 'invalid'}`);
if (result.data.valid) {
console.log(`Company: ${result.data.company_name}`);
console.log(`Address: ${result.data.address}`);
}
} else {
console.error(`Error: ${result.message}`);
}
}
// Example: Get VAT rates for Germany
async function getVatRates() {
const result = await callApi('rates', { country_code: 'DE' });
if (result.success) {
console.log(`Standard rate: ${result.data.DE.standard_rate}%`);
console.log(`Reduced rate: ${result.data.DE.reduced_rates.reduced}%`);
} else {
console.error(`Error: ${result.message}`);
}
}
// Example: Calculate VAT
async function calculateVat() {
const result = await callApi('calculate', {
amount: 100,
country_code: 'DE',
rate_type: 'standard'
});
if (result.success) {
console.log(`Amount: €${result.data.amount}`);
console.log(`VAT amount: €${result.data.vat_amount}`);
console.log(`Total: €${result.data.total_amount}`);
} else {
console.error(`Error: ${result.message}`);
}
}
// Call the functions
validateVat();
getVatRates();
calculateVat();
Here's how to use the API with cURL:
# Your API key
API_KEY="YOUR_API_KEY"
# Base URL
BASE_URL="https://api.thevatapi.com"
# Example: Validate VAT number
VAT_NUMBER="LU26375245"
curl -G "${BASE_URL}/validate" \
--data-urlencode "api_key=${API_KEY}" \
--data-urlencode "vat_number=${VAT_NUMBER}"
# Example: Get VAT rates for Germany
curl -G "${BASE_URL}/rates" \
--data-urlencode "api_key=${API_KEY}" \
--data-urlencode "country_code=DE"
# Example: Get all VAT rates
curl -G "${BASE_URL}/all_rates" \
--data-urlencode "api_key=${API_KEY}"
# Example: Calculate VAT
curl -G "${BASE_URL}/calculate" \
--data-urlencode "api_key=${API_KEY}" \
--data-urlencode "amount=100" \
--data-urlencode "country_code=DE" \
--data-urlencode "rate_type=standard"