How to Validate a VAT Number using Go

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))
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloudmersive

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