VAT Calculation
Finance Math & Calculations Credits / request: 1Adds VAT to a net amount or extracts VAT from a gross amount. Rate is a parameter.
GET
https://api.apikodu.com/api/v1/math/vat
Documentation
Overview
Calculates VAT net, tax and gross. Whether amount is net or gross is decided by mode.
Authentication
Every request requires the x-api-key header. Credits used and remaining quota are returned in response headers (x-api-credits-used, x-api-remaining-credits, x-rate-limit-*).
Request
GET
https://api.apikodu.com/api/v1/math/vat?amount=1000&rate=20&mode=add¤cy=EUR
Parameters are sent as a query string.
Parameters
| Name | Type | Required | Default | Options | Description |
|---|---|---|---|---|---|
amount |
number | * Required | — | — | 0 .. 999999999999.99. add/split: net, extract: gross. |
rate |
number | * Required | — | — | VAT % . 0 .. 1000. |
mode |
string | Optional | add |
add extract split |
add: add to net. extract: extract from gross. split: currently same as add. |
currency |
string | Optional | — | — | ISO code. Empty → null. |
Response
| Name | Type | Description |
|---|---|---|
amountNet |
number | Net amount excluding VAT. Rounded to 2 decimals with AwayFromZero. |
amountTax |
number | VAT amount = gross − net. 2 decimals. |
amountGross |
number | Gross amount including VAT. 2 decimals. |
rate |
number | Applied VAT rate (%). Same as the request rate. |
currency |
string | ISO currency code. Null if omitted. |
mode |
string | Applied mode: add, extract or split. |
Errors
| HTTP | code | Description |
|---|---|---|
400 |
-241 |
amount or rate is missing, not a number, or out of range (amount 0..999999999999.99, rate 0..1000). |
400 |
-242 |
mode is not add, extract or split. |
401 |
-100 |
x-api-key is missing, empty, malformed, inactive, banned, expired, IP-restricted, or not allowed for this API. |
429 |
-221 |
Per-minute request limit exceeded. Response headers: x-rate-limit-limit, x-rate-limit-remaining, x-rate-limit-reset. |
429 |
— | Package credit quota cannot cover this request. Body may be { error, limit, currentUsage, requestCost } (no code field). |
500 |
-1 |
Unexpected server error. message is a generic error text without technical details. |
Notes
- Success body is { data: { ... } }. Error body is { code, message }. code is an ApiResponseCode enum value (negative integer).
- Money fields are rounded to 2 decimals with AwayFromZero.
Sample response
{
"data": {
"amountNet": 1000.00,
"amountTax": 200.00,
"amountGross": 1200.00,
"rate": 20.0,
"currency": "EUR",
"mode": "add"
}
}
Code samples
const response = await fetch('https://api.apikodu.com/api/v1/math/vat', {
method: 'GET',
headers: {
'x-api-key': 'YOUR_API_KEY'
}
});
const data = await response.json();
console.log(data);
import requests
headers = {
'x-api-key': 'YOUR_API_KEY'
}
response = requests.get('https://api.apikodu.com/api/v1/math/vat', headers=headers)
print(response.json())
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("x-api-key", "YOUR_API_KEY");
var response = await client.GetStringAsync("https://api.apikodu.com/api/v1/math/vat");
Console.WriteLine(response);
$response = file_get_contents('https://api.apikodu.com/api/v1/math/vat', false, stream_context_create([
'http' => [
'header' => "x-api-key: YOUR_API_KEY"
]
]));
print_r(json_decode($response, true));
curl -X GET 'https://api.apikodu.com/api/v1/math/vat' \
-H 'x-api-key: YOUR_API_KEY'
Start building in minutes
Create a free account, get your API key and send your first request in minutes.