Home > Uncategorized > Verify a #SouthAfrican #VAT number via an API

Verify a #SouthAfrican #VAT number via an API

If your company deals with South African companies, and you need to verify the VAT number provided by them, to ensure it matches the same company, then here is an API that can do this automatically for you.

Firstly, register with RapidAPI, and go to this page https://rapidapi.com/appaio/api/south-african-vat-api once registered, you will get a RapidAPI key, which you will need to run the below code example;

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RestSharp;

var client = new RestClient("https://south-african-vat-api.p.rapidapi.com/default/ZAVAT");

var request = new RestRequest
    Method = Method.Post
request.AddHeader("X-RapidAPI-Key", "**********");
request.AddHeader("X-RapidAPI-Host", "south-african-vat-api.p.rapidapi.com");
request.AddHeader("Content-Type", "application/json");
var body = JsonConvert.SerializeObject(new { vat = "4910202524" });
request.AddParameter("application/json", body, ParameterType.RequestBody);
var response = client.Execute(request);
var company = JObject.Parse(response.Content ?? "{}");
var resultTable = company["Table"] ?? new JObject();
var tradingName = resultTable["TRADING NAME"] + "";
var area = resultTable["AREA DESC"] + "";
Console.WriteLine($"{tradingName} is registered in {area}");

The code above is a console app for .NET Core in C#, and will require the following NuGet packages, which can be installed as follows;

Install-Package RestSharp 
Install-Package Newtonsoft.JSON
Categories: Uncategorized
  1. Lee
    October 1, 2022 at 7:49 am

    Wow man, that is amazing….you done all this yourself?


  1. September 9, 2022 at 9:52 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: