Calculate VAT

Add VAT to a net amount or extract the VAT component from a gross amount for any African country.

POST https://afrotools.com/api/vat
Authentication required. Pass your API key via x-api-key header. Learn more

Request Body

Send a JSON body with the following parameters:

ParameterTypeDescription
country required string ISO 3166-1 alpha-2 country code (e.g., NG, KE, ZA).
amount required number The monetary amount in local currency. Must be a positive number.
mode required string Calculation mode: add (add VAT to net amount) or extract (extract VAT from gross amount).
rate_type optional string VAT rate category: standard (default), reduced, or zero.
category optional string Product category for rate lookup: standard, food_basic, medical, education, digital, export.

Response Fields

FieldTypeDescription
countrystringISO country code.
country_namestringFull country name.
currencystringISO currency code.
modestringCalculation mode used (add or extract).
net_amountnumberAmount before VAT.
vat_ratenumberVAT rate applied (%).
vat_amountnumberVAT component.
gross_amountnumberAmount including VAT.
rate_typestringRate category applied.
updatedstringDate the VAT rate was last updated.

Error Responses

StatusCodeDescription
400INVALID_COUNTRYThe country code is not supported.
400INVALID_SALARYThe amount must be a positive number.
400MISSING_REQUIRED_FIELDA required field (country, amount, or mode) is missing.
401INVALID_API_KEYNo valid API key was provided.
429RATE_LIMIT_EXCEEDEDRate limit exceeded for your plan.
Request Examples
curl -X POST https://afrotools.com/api/vat \ -H "x-api-key: afro_live_your_key_here" \ -H "Content-Type: application/json" \ -d '{ "country": "NG", "amount": 100000, "mode": "add" }'
const res = await fetch("https://afrotools.com/api/vat", { method: "POST", headers: { "x-api-key": "afro_live_your_key_here", "Content-Type": "application/json" }, body: JSON.stringify({ country: "NG", amount: 100000, mode: "add" }) }); const data = await res.json(); console.log(`VAT: ${data.data.vat_amount}`);
import requests resp = requests.post( "https://afrotools.com/api/vat", headers={"x-api-key": "afro_live_your_key_here"}, json={ "country": "NG", "amount": 100000, "mode": "add" } ) data = resp.json() print(f"VAT: {data['data']['vat_amount']} NGN")
const axios = require("axios"); const { data } = await axios.post( "https://afrotools.com/api/vat", { country: "NG", amount: 100000, mode: "add" }, { headers: { "x-api-key": "afro_live_your_key_here" } } ); console.log(`VAT: ${data.data.vat_amount} NGN`);
$payload = json_encode([ "country" => "NG", "amount" => 100000, "mode" => "add" ]); $ch = curl_init("https://afrotools.com/api/vat"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "x-api-key: afro_live_your_key_here", "Content-Type: application/json" ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); echo "VAT: " . $data["data"]["vat_amount"] . " NGN";

Response — Add Mode (200 OK)
{ "success": true, "data": { "country": "NG", "country_name": "Nigeria", "currency": "NGN", "mode": "add", "net_amount": 100000, "vat_rate": 7.5, "vat_amount": 7500, "gross_amount": 107500, "rate_type": "standard", "updated": "2026-01-01" } }

Response — Extract Mode
# Extract VAT from 107,500 NGN { "success": true, "data": { "country": "NG", "country_name": "Nigeria", "currency": "NGN", "mode": "extract", "net_amount": 100000, "vat_rate": 7.5, "vat_amount": 7500, "gross_amount": 107500, "rate_type": "standard", "updated": "2026-01-01" } }

Error Response (400)
{ "success": false, "error": { "code": "MISSING_REQUIRED_FIELD", "message": "The 'mode' field is required. Use 'add' or 'extract'.", "docs": "https://afrotools.com/docs/api/vat/calculate.html" } }