Archive for September, 2022

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 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("");

var request = new RestRequest
    Method = Method.Post
request.AddHeader("X-RapidAPI-Key", "**********");
request.AddHeader("X-RapidAPI-Host", "");
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
%d bloggers like this: