How to Use vatcheckapi.com API in JavaScript?

vatcheckapi.com is a free API that allows you to validate and retrieve VAT numbers from the European Union VAT database. In this blog, we’ll be discussing how to use this API with JavaScript.

Getting Started

First, sign up for a free account on the vatcheckapi.com website. You will receive an API key, which you will need to use the service.

To use the API, we need to make an HTTP request to the URL:

https://api.vatcheckapi.com/v1/verify

To make this request, we’ll use the fetch function in JavaScript.

Validate a VAT Number

To validate a VAT number, send an HTTP GET request to the verify endpoint with the VAT number and API key as parameters. Here’s an example code snippet:

const apiKey = 'YOUR_API_KEY';
const vatNumber = 'GB980780684';

fetch(`https://api.vatcheckapi.com/v1/verify?vat_number=${vatNumber}&api_key=${apiKey}`)
    .then(response => response.json())
    .then(data => console.log(data));

This will log the response data in the console that includes the validation result, country code, and other details.

Retrieve VAT Details

To retrieve VAT details, send an HTTP GET request to the details endpoint with the VAT number and API key as parameters. Here’s an example code snippet:

const apiKey = 'YOUR_API_KEY';
const vatNumber = 'GB980780684';

fetch(`https://api.vatcheckapi.com/v1/details?vat_number=${vatNumber}&api_key=${apiKey}`)
    .then(response => response.json())
    .then(data => console.log(data));

This will log the response data in the console that includes the VAT number, registered name, address, and other details.

Conclusion

Using the vatcheckapi.com API in JavaScript is straightforward. You can use it to validate and retrieve VAT details from the European Union VAT database. With the code examples provided in this blog post, you should be able to get up and running with this API in no time!

Related APIs

Public APIs — A directory of free and public apis

Built by @mddanishyusuf