Programming libraries allows you to search for entrepreneurs data based on the entered VAT EU number. Currently, API libraries are available for the following programming languages:

  • .NET (C#, Visual Basic)
  • Java
  • JavaScript (Node.js)
  • PHP
  • Python
  • C/C++

API provides the following features:

  • getVIESData – function to confirm the activity of the EU VAT number assigned by any of the European Union Member States,
  • getAccountStatus –function for retrieving up-to-date information about the user account.

Integration

All libraries with source codes are available for download on the Download page. In addition, the source code for the libraries is also available in our official repository on Github.

The way of integrating the library depends on the selected programming language. For those languages ​​that support library management based on a central repository, it is possible to use it.

// NuGet Gallery
// https://www.nuget.org/packages/VIESAPI.VIESAPIClient

PM> Install-Package VIESAPI.VIESAPIClient
// No central repository support
// Maven
// https://viesapi.eu/public/maven

<repository>
    <id>viesapi</id>
    <url>https://viesapi.eu/public/maven</url>
</repository>

<dependency>
    <groupId>eu.viesapi</groupId>
    <artifactId>viesapi-client</artifactId>
    <version>1.2.5</version>
</dependency>
// NPM
// https://www.npmjs.com/package/viesapi-client

npm install viesapi-client
// Packagist (Composer)
// https://packagist.org/packages/viesapi/client

composer require viesapi/client
# No central repository support

pip install viesapi-python-client-1.2.3.zip
' No central repository support

Authentication

In order to perform the correct authentication, the correct values ​​of the id and key parameters should be provided during the construction of the client object. The id parameter should contain a valid key identifier used for authorization. The key parameter should contain a valid value of the key used for authorization. The key identifier and the key are generated by the user after logging in to his account on the viesapi.eu portal. The process of generating the keys and identifiers has been detailed above.

The following example illustrates how to use the library functions:

using viesapiLibrary.dll;

// Create the service client object
// id - a string representing the API key identifier
// key - a string representing the API key
VIESAPIClient viesapi = new VIESAPIClient("id", "key");
#include "viesapi.h"

// Create the service client object
// id - a string representing the API key identifier
// key - a string representing the API key
VIESAPIClient* viesapi = NULL;
viesapi_new_prod(&viesapi, "id", "key");
import pl.viesapi.client.*;

// Create the service client object
// id - a string representing the API key identifier
// key - a string representing the API key
VIESAPIClient viesapi = new VIESAPIClient("id", "key");
var VIESAPI = require('viesapiclient');

// Create the service client object
// id - a string representing the API key identifier
// key - a string representing the API key
var viesapi = new VIESAPI.VIESAPIClient('id', 'key');
require_once 'VIESAPI/VIESAPIClient.php';

\VIESAPI\VIESAPIClient::registerAutoloader();

// Create the service client object
// id - a string representing the API key identifier
// key - a string representing the API key
$viesapi = new \VIESAPI\VIESAPIClient('id', 'key');
from viesapi import *
from pprint import pprint

// Create the service client object
// id - a string representing the API key identifier
// key - a string representing the API key
viesapi = VIESAPIClient('id', 'key')
' Create the service client object
' id - a string representing the API key identifier
' key - a string representing the API key
Dim viesapi As New VIESAPIClient
viesapi.URL = "https://www.viesapi.eu/api"
viesapi.Id = "id"
viesapi.Key = "key"

Attention! The current time of the client’s computer is used during the authentication process. Therefore in case of authentication problems when trying to connect to the viesapi.eu system, first make sure that the computer or server from which the connection is established has the correct current time and time zone. More information on the method used by the viesapi.eu system to authenticate inquiries can be found here.

Checking EU VAT numbers

The EU VAT number is confirmed by calling the getVIESData() function, the parameter of which is the EU VAT number that we want to verify. The function enables the verification of EU VAT numbers issued by all member states of the European Union.

The following example illustrates how functions are used in libraries:

// A call to a method that returns data from a VIES system
VIESData vies = viesapi.GetVIESData("PL1234567890");

if (vies != null) {
	Console.WriteLine(vies);
}
else {
	Console.WriteLine("Error: " + viesapi.LastError);
}
// A call to a method that returns data from a VIES system
VIESData* vies = viesapi_get_vies_data(viesapi, "PL1234567890");

if (vies != NULL) {
	printf("Kraj: %s\n", vies->CountryCode);
	printf("VAT ID: %s\n", vies->VATNumber);
	printf("Aktywny: %d\n", vies->Valid);
}
else {
	printf("Error: %s\n", viesapi_get_last_err(viesapi));
}
// A call to a method that returns data from a VIES system
VIESData vies = viesapi.getVIESData("PL1234567890");

if (vies != null) {
	System.out.println(vies);
}
else {
	System.out.println("Error: " + viesapi.getLastError());
}
// A call to a method that returns data from a VIES system
viesapi.getVIESData('PL1234567890').then((vies) => {
	console.log(vies.toString());
}).catch((e) => {
	console.log(e.message);
});
// A call to a method that returns data from a VIES system
$vies = $viesapi->get_vies_data('PL1234567890');

if ($vies) {
	print_r($vies);
}
else {
	echo '<p>Error: ' . $viesapi->get_last_error() . '</p>';
}
# A call to a method that returns data from a VIES system
vies = viesapi.get_vies_data('PL1234567890')

if vies:
    pprint(vars(vies))
else:
    print u'Error: ' + viesapi.get_last_error()
' A call to a method that returns data from a VIES system
Dim vies As VIESData
Set vies = viesapi.GetVIESData("PL1234567890")

If vies Is Nothing Then
	Console.WriteLine("Error: {0}", viesapi.LastError)
Else
	Console.WriteLine(vies.ToString())
End If

Retrieving information about the user’s account status

The function allows you to download all the basic information about the user account, which is displayed after logging in to the account on the viesapi.eu portal. The function also returns information about the maximum number of queries available under the selected plan (e.g. 5,000 for the Business plan) and the total number of all queries made in the current month on the user’s account.

Attention! Calling the function does not increase the number of queries made.

The following example illustrates how to use the library functions.

// Get current account status
AccountStatus account = viesapi.GetAccountStatus();

if (account != null) {
     Console.WriteLine(account);
}
else {
     Console.WriteLine("Error: " + viesapi.LastError);
}
// Get current account status
AccountStatus* account = viesapi_get_account_status(viesapi);

if (account != NULL) {
	printf("Plan name: %s\n", account->BillingPlanName);
	printf("Price: %.2f\n", account->SubscriptionPrice);
	printf("Number of queries: %d\n", account->TotalCount);
}
else {
	printf("Error: %s\n", viesapi_get_last_err(viesapi));
}
// Get current account status
AccountStatus account = viesapi.getAccountStatus();

if (account != null) {
     System.out.println(account);
}
else {
     System.err.println("Error: " + viesapi.getLastError());
}
// Get current account status
viesapi.getAccountStatus().then((account) => {
	console.log(account.toString());
}).catch((e) => {
	console.log(e.message);
});
// Get current account status
$account = $viesapi->get_account_status();

if ($account) {
     echo '<p>' . print_r($account, true) . '</p>';
}
else {
     echo '<p>Error: ' . $viesapi->get_last_error() . '</p>';
}
# Get current account status
account = viesapi.get_account_status()

if account:
    pprint(vars(account))
else:
    print u'Error: ' + viesapi.get_last_error()
'Get current account status
Dim account As AccountStatus
Set account = viesapi.GetAccountStatus()

If account Is Nothing Then
	Console.WriteLine("Error: {0}", viesapi.LastError)
Else
	Console.WriteLine(account.ToString())
End If

Registering a .NET library as a COM object

The viesapiLibrary.dll library can be registered in the Windows system as the so-called COM object. Then the functions of the library can be referenced from many different programming languages and ready-made applications, incl. Microsoft Excel, Access, SQL Server, Dynamics or Visual FoxPro.

To register a library as a COM object, follow these steps:

  1. Download the .NET library archive and unpack it on a local disk to any location.
  2. Go to the directory with unpacked library files and find the com-register.bat file.
  3. Select the com-register.bat file with the mouse and select the Run as administrator command from the context menu.

Using the .NET library in MS Excel

The functions of the viesapiLibrary.dll library can be used in the MS Excel application to write your own functions and procedures in the Visual Basic language. To make it possible, it is necessary to:

  1. Register the viesapiLibrary.dll library as a COM object on Windows.
  2. Start the Excel application. Select the DEVELOPER tab on the ribbon and then click the Visual Basic button.
  3. In the Visual Basic for Application window, select Tools and then References from the menu. In the Available References list, find and select VIESAPI Service Client for .NET Framework (C#). Confirm your selection with the OK button.
  4. From the Insert menu, choose Module and paste the function code presented in the examples for Visual Basic in the new window.
  5. Finally, appropriate values of w for viesapi.ID and viesapi.Key should be set. The method of obtaining the key and the access key is described in the chapter Generating the identifier and access key