How to Validate a VAT Number using Go

Cloudmersive
2 min readDec 5, 2022

--

If you’re running a business in an EU nation, validating VAT codes is an important way of rooting out fraudulent business activity. Thankfully, our VAT Code Validation API is an easy-to-use solution designed to assist in this common business need, and it can be built into your applications for free (using a free-tier Cloudmersive API key obtainable on our website) by structuring an API call with the ready-to-run Go code examples provided below.

In its response, this API will first determine the validity of the input VAT code and subsequently provide an exhaustive list of relevant information including the name, address, building, street number, street, city & province of the associated business (and more).

To take advantage of this API, simply copy the below code examples into your environment, and supply your VAT code as a string value. Your API key can then be entered in the relevant field (clearly indicated within the code):

package main

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

func main() {

url := "https://api.cloudmersive.com/validate/vat/lookup"
method := "POST"

payload := strings.NewReader(`{
"VatCode": "<string>"
}`)

client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)

if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Apikey", "YOUR-API-KEY-HERE")

res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()

body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet