vatlayer API
Data ValidationVatlayer API Documentation
Vatlayer API is a free and simple REST API for performing VAT number validation. The API allows you to validate VAT numbers from all EU member states and some other countries. In this post, we will walk through how to use the Vatlayer API using JavaScript.
Getting Started
Before you can use the Vatlayer API, you need to sign up for a free API key on the website. Once you have your API key, you can start making requests to the API.
Validating a VAT Number
To validate a VAT number, you need to make a GET request to the API endpoint with the VAT number and your API key as parameters. Here's an example code snippet in JavaScript:
const apiKey = 'YOUR_API_KEY';
const vatNumber = 'GB980780684';
fetch(`http://apilayer.net/api/vat_number_validation?access_key=${apiKey}&vat_number=${vatNumber}`)
.then(response => response.json())
.then(data => console.log(data));
In the above example, we are using the fetch()
function to make a GET request to the Vatlayer API endpoint with the VAT number and API key as parameters. The API will validate the VAT number and return a JSON response that contains the validation result.
Response Format
The response from the Vatlayer API will be in JSON format with the following properties:
valid
: Whether the VAT number is valid or not.query
: The query VAT number that was passed to the API.company_name
: The name of the company that the VAT number belongs to.company_address
: The address of the company that the VAT number belongs to.company_country_code
: The country code of the country that the VAT number belongs to.company_vat_number
: The validated VAT number.
Here's an example response from the Vatlayer API:
{
"valid": true,
"query": "GB980780684",
"company_name": "APPLE RETAIL UK LIMITED",
"company_address": "1 HANOVER STREET LONDON W1S 1YZ",
"company_country_code": "GB",
"company_vat_number": "GB980780684"
}
Conclusion
Vatlayer API provides a simple and free way to validate VAT numbers from multiple countries. With just a few lines of JavaScript code, you can easily integrate the API into your application.