Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

VAT Number Validator (EU & UK)

A customer types DE13669597 into your checkout — one digit short — and nobody notices until the invoice bounces back from their accounts department three weeks later. Or worse: you zero-rate a cross-border B2B sale, the VAT number turns out to be deregistered, and you are on the hook for the tax when the audit comes.

Validating VAT numbers properly means handling two different problems. First, syntax: every country has its own format and check-digit algorithm (Germany's differs from Italy's, which differs from Ireland's). Second, registration: a well-formed number can still belong to nobody, because companies deregister, merge, or were never registered at all. Checking registration means talking to EU VIES and UK HMRC — two separate services with different request formats, quirks, and downtime windows.

This API does both in one call. GET /validate?vat=DE136695976&country=DE gives you instant offline format and check-digit validation for all 27 EU member states plus Great Britain and Northern Ireland; /lookup goes to the official registries and returns the registered company name and address. No scraping, no stale mirrors.

Typical uses:

  • Checkout forms — reject typos inline before the order is placed
  • Invoicing / ERP — confirm a counterparty is VAT-registered before zero-rating
  • CRM cleanup — batch-validate an entire customer database via /validate-batch
  • Compliance records — store the registry-confirmed name and address as audit evidence

Get started

  1. Subscribe (free tier available) on RapidAPI and copy your X-RapidAPI-Key.
  2. Call the API — here's the primary endpoint in every major language.

Base URL: https://vat-number-validator-eu-uk.p.rapidapi.com

Code examples

cURL

curl --request GET \
  --url 'https://vat-number-validator-eu-uk.p.rapidapi.com/validate?vat=DE136695976&country=DE' \
  --header 'X-RapidAPI-Key: YOUR_RAPIDAPI_KEY' \
  --header 'X-RapidAPI-Host: vat-number-validator-eu-uk.p.rapidapi.com'

Python

import requests

url = "https://vat-number-validator-eu-uk.p.rapidapi.com/validate"
querystring = {"vat": "DE136695976", "country": "DE"}
headers = {
    "X-RapidAPI-Key": "YOUR_RAPIDAPI_KEY",
    "X-RapidAPI-Host": "vat-number-validator-eu-uk.p.rapidapi.com",
}

response = requests.get(url, headers=headers, params=querystring)
print(response.json())

JavaScript (fetch)

const url = 'https://vat-number-validator-eu-uk.p.rapidapi.com/validate?vat=DE136695976&country=DE';
const options = {
  method: 'GET',
  headers: {
    'X-RapidAPI-Key': 'YOUR_RAPIDAPI_KEY',
    'X-RapidAPI-Host': 'vat-number-validator-eu-uk.p.rapidapi.com',
  },
};

const response = await fetch(url, options);
console.log(await response.json());

Node.js (axios)

import axios from 'axios';

const options = {
  method: 'GET',
  url: 'https://vat-number-validator-eu-uk.p.rapidapi.com/validate',
  params: {vat: 'DE136695976', country: 'DE'},
  headers: {
    'X-RapidAPI-Key': 'YOUR_RAPIDAPI_KEY',
    'X-RapidAPI-Host': 'vat-number-validator-eu-uk.p.rapidapi.com',
  },
};

const { data } = await axios.request(options);
console.log(data);

TypeScript

const url = 'https://vat-number-validator-eu-uk.p.rapidapi.com/validate?vat=DE136695976&country=DE';

const response = await fetch(url, {
  method: 'GET',
  headers: {
    'X-RapidAPI-Key': 'YOUR_RAPIDAPI_KEY',
    'X-RapidAPI-Host': 'vat-number-validator-eu-uk.p.rapidapi.com',
  } as Record<string, string>,
});

const data: unknown = await response.json();
console.log(data);

PHP

<?php
$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL => "https://vat-number-validator-eu-uk.p.rapidapi.com/validate?vat=DE136695976&country=DE",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY",
        "X-RapidAPI-Host: vat-number-validator-eu-uk.p.rapidapi.com",
    ],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Ruby

require 'uri'
require 'net/http'

url = URI("https://vat-number-validator-eu-uk.p.rapidapi.com/validate?vat=DE136695976&country=DE")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["X-RapidAPI-Key"] = 'YOUR_RAPIDAPI_KEY'
request["X-RapidAPI-Host"] = 'vat-number-validator-eu-uk.p.rapidapi.com'

response = http.request(request)
puts response.read_body

Java (OkHttp)

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
    .url("https://vat-number-validator-eu-uk.p.rapidapi.com/validate?vat=DE136695976&country=DE")
    .get()
    .addHeader("X-RapidAPI-Key", "YOUR_RAPIDAPI_KEY")
    .addHeader("X-RapidAPI-Host", "vat-number-validator-eu-uk.p.rapidapi.com")
    .build();

Response response = client.newCall(request).execute();
System.out.println(response.body().string());

C#

using var client = new HttpClient();
var request = new HttpRequestMessage
{
    Method = HttpMethod.Get,
    RequestUri = new Uri("https://vat-number-validator-eu-uk.p.rapidapi.com/validate?vat=DE136695976&country=DE"),
    Headers =
    {
        { "X-RapidAPI-Key", "YOUR_RAPIDAPI_KEY" },
        { "X-RapidAPI-Host", "vat-number-validator-eu-uk.p.rapidapi.com" },
    },
};

using var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

Go

package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://vat-number-validator-eu-uk.p.rapidapi.com/validate?vat=DE136695976&country=DE", nil)
    req.Header.Add("X-RapidAPI-Key", "YOUR_RAPIDAPI_KEY")
    req.Header.Add("X-RapidAPI-Host", "vat-number-validator-eu-uk.p.rapidapi.com")

    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)
    fmt.Println(string(body))
}

Rust

use reqwest::header::{HeaderMap, HeaderValue};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut headers = HeaderMap::new();
    headers.insert("X-RapidAPI-Key", HeaderValue::from_static("YOUR_RAPIDAPI_KEY"));
    headers.insert("X-RapidAPI-Host", HeaderValue::from_static("vat-number-validator-eu-uk.p.rapidapi.com"));

    let client = reqwest::Client::new();
    let res = client.get("https://vat-number-validator-eu-uk.p.rapidapi.com/validate?vat=DE136695976&country=DE").headers(headers).send().await?;
    println!("{}", res.text().await?);
    Ok(())
}

Swift

import Foundation

var request = URLRequest(url: URL(string: "https://vat-number-validator-eu-uk.p.rapidapi.com/validate?vat=DE136695976&country=DE")!)
request.httpMethod = "GET"
request.setValue("YOUR_RAPIDAPI_KEY", forHTTPHeaderField: "X-RapidAPI-Key")
request.setValue("vat-number-validator-eu-uk.p.rapidapi.com", forHTTPHeaderField: "X-RapidAPI-Host")

let (data, _) = try await URLSession.shared.data(for: request)
print(String(data: data, encoding: .utf8)!)

Kotlin

val client = OkHttpClient()

val request = Request.Builder()
    .url("https://vat-number-validator-eu-uk.p.rapidapi.com/validate?vat=DE136695976&country=DE")
    .get()
    .addHeader("X-RapidAPI-Key", "YOUR_RAPIDAPI_KEY")
    .addHeader("X-RapidAPI-Host", "vat-number-validator-eu-uk.p.rapidapi.com")
    .build()

val response = client.newCall(request).execute()
println(response.body?.string())

Shell (wget)

wget -qO- \
  --header='X-RapidAPI-Key: YOUR_RAPIDAPI_KEY' \
  --header='X-RapidAPI-Host: vat-number-validator-eu-uk.p.rapidapi.com' \
  'https://vat-number-validator-eu-uk.p.rapidapi.com/validate?vat=DE136695976&country=DE'

Endpoints

Method Path Description
GET /validate Validate a VAT number offline (format + check digits)
GET /lookup Live registry lookup (VIES / HMRC) with company name & address
POST /validate-batch Validate up to 100 VAT numbers in one call (offline)
GET /countries List supported countries, formats and lookup services

How to validate EU and UK VAT numbers before zero-rating a B2B sale

Read the full guide: How to validate EU and UK VAT numbers before zero-rating a B2B sale


⭐ Powered by the VAT Number Validator (EU & UK) API on RapidAPI.

About

Validate EU & UK VAT numbers by API: instant checksum checks plus live VIES and HMRC lookups returning company name and address. Batch cleaning included.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors