SDKs overview

VAT Validation offers a suite of Software Development Kits (SDKs) and client libraries designed to facilitate integration with its VAT validation API. These SDKs are developed to simplify the process of verifying VAT numbers for businesses operating across different jurisdictions, ensuring compliance with tax regulations and aiding in fraud prevention. The available SDKs abstract the complexities of direct API interaction, providing developers with language-specific methods to access VAT Validation's core functionalities, such as validating a VAT number and querying its status.

The API itself operates on a SOAP-based interface, as defined by the European Commission's VIES system, which is the authoritative source for VAT number validation within the EU. While the underlying VIES system uses SOAP, VAT Validation provides a RESTful wrapper API, making it accessible through standard HTTP requests and offering a more modern integration approach. This design choice allows developers to interact with the service using familiar web technologies and readily available client libraries.

The SDKs provided by VAT Validation are intended to reduce development time by handling HTTP requests, response parsing, and error handling specific to the VAT Validation API. This allows developers to focus on integrating VAT validation logic into their applications without needing to manage the low-level details of API communication. The documentation includes code examples to assist with quick implementation across various programming environments.

Official SDKs by language

VAT Validation provides official SDKs for several popular programming languages, ensuring broad compatibility for developers. These SDKs are maintained to reflect the current API specifications and provide a consistent interface for interacting with the VAT Validation service. Each SDK is designed to offer a native experience within its respective language ecosystem, adhering to common coding conventions and best practices.

Language Package Name / Identifier Maturity Documentation
PHP vat-validation/api-client Stable PHP SDK documentation
Java com.vatvalidation:vat-api-client Stable Java SDK documentation
Python vat_validation_api Stable Python SDK documentation
Ruby vat_validation_api Stable Ruby SDK documentation
Node.js vat-validation-api Stable Node.js SDK documentation

Installation

Installing the VAT Validation SDKs typically involves using the standard package manager for each programming language. The following instructions provide general guidance for installing the official client libraries. For specific version requirements or advanced configurations, developers should refer to the official VAT Validation developer documentation.

PHP

The PHP SDK can be installed via Composer, the dependency manager for PHP. Ensure Composer is installed on your system.

composer require vat-validation/api-client

Java

For Java projects, you can add the SDK as a dependency in your Maven pom.xml or Gradle build file. For Maven:

<dependency>
    <groupId>com.vatvalidation</groupId>
    <artifactId>vat-api-client</artifactId>
    <version>1.0.0</version> <!-- Use the latest version -->
</dependency>

For Gradle:

implementation 'com.vatvalidation:vat-api-client:1.0.0' // Use the latest version

Python

The Python SDK is available on PyPI and can be installed using pip.

pip install vat_validation_api

Ruby

The Ruby gem can be installed using Bundler or directly via gem install.

gem install vat_validation_api

Alternatively, add it to your Gemfile:

gem 'vat_validation_api'

Then run bundle install.

Node.js

The Node.js SDK can be installed using npm or yarn.

npm install vat-validation-api

Or with yarn:

yarn add vat-validation-api

Quickstart example

The following examples demonstrate how to use the VAT Validation SDKs to validate a VAT number. These snippets illustrate a basic integration pattern. Developers should replace YOUR_API_KEY with their actual API key obtained from the VAT Validation dashboard.

PHP Quickstart

<?php
require_once 'vendor/autoload.php';

use VatValidation\ApiClient;

$apiKey = 'YOUR_API_KEY';
$client = new ApiClient($apiKey);

try {
    $vatNumber = 'NL001234567B01';
    $validationResult = $client->validateVat($vatNumber);

    if ($validationResult->isValid()) {
        echo "VAT Number is valid: " . $validationResult->getVatNumber() . "\n";
        echo "Company Name: " . $validationResult->getCompanyName() . "\n";
        echo "Address: " . $validationResult->getCompanyAddress() . "\n";
    } else {
        echo "VAT Number is invalid or an error occurred.\n";
        echo "Error: " . $validationResult->getError() . "\n";
    }
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
}
?>

JavaScript (Node.js) Quickstart

const VatValidationApi = require('vat-validation-api');

const apiKey = 'YOUR_API_KEY';
const client = new VatValidationApi(apiKey);

async function validateVatNumber() {
    try {
        const vatNumber = 'DE123456789';
        const validationResult = await client.validateVat(vatNumber);

        if (validationResult.isValid) {
            console.log(`VAT Number is valid: ${validationResult.vatNumber}`);
            console.log(`Company Name: ${validationResult.companyName}`);
            console.log(`Address: ${validationResult.companyAddress}`);
        } else {
            console.log('VAT Number is invalid or an error occurred.');
            console.log(`Error: ${validationResult.error}`);
        }
    } catch (error) {
        console.error('Error:', error.message);
    }
}

validateVatNumber();

Community libraries

While VAT Validation provides official SDKs for several key programming languages, the RESTful nature of its API also permits integration using generic HTTP client libraries available in virtually any programming environment. Developers can choose to build custom integrations directly against the VAT Validation API endpoints if an official SDK is not available for their preferred language or if they require highly customized request handling.

For example, in languages without a dedicated official SDK, developers might use common HTTP client libraries such as requests in Python, axios or fetch in JavaScript, or HttpClient in Java. These libraries allow for direct construction and sending of HTTP requests to the API, and parsing of the JSON responses. This approach requires manual handling of authentication, request formatting, and error parsing, which the official SDKs automate.

The developer community also contributes various tools and wrappers that can simplify interaction with such APIs. While VAT Validation does not officially endorse specific community-maintained libraries, the open nature of API development means that developers often share their solutions. These might be found on platforms like GitHub or package repositories, though their maintenance and reliability can vary. When considering a community-contributed library, it is advisable to review its source code, community support, and update frequency to ensure it meets project requirements and security standards. Developers can also consult general guidelines for consuming REST APIs with Fetch API for web-based applications or Google Cloud's API design guidelines for best practices in API integration.