Description

The VatAPI.calculate() method is used to communicate with this endpoint as seen below: VatAPI.calculate(amount, country_code, Optional[is_vat_incl, vat_category])

Query Parameters

Below are the query parameters for this method:
amount
String
required
The amount that you would like to get the VAT amount for or from.
  • For: That is, vat is not included in the price and you want to add it.
  • From: That is, vat is already included in the price and you want to extract it
country_code
String
required
The two letter ISO 3166-1 alpha-2 code of the country in which the transaction takes place.
is_vat_incl
Boolean
Used to declare if vat fee has already been included in the amount. If the amount already has VAT added, set this to True. The response data will split out the amount and VAT. If this parameter is not set, it will default to false.
vat_category
String
Some countries offer a reduced VAT rate for certain categories of goods. To determine if a reduced VAT is available and to apply it to the final amount, include the vat_category in the request.

Usage

Below is a code snippet to query the VatAPI.calculate() method:
from abstract_python import VatAPI

api_key = "your-vat-api-key"

api = VatAPI(api_key)
amount = "50"
country_code = "BE"
response = api.calculate(amount, country_code)

print(response)

Below is the response object:
{
    'amount_excluding_vat': '50.00', 
    'amount_including_vat': '60.50', 
    'vat_amount': '10.50', 
    'vat_category': 'standard', 
    'vat_rate': '0.210', 
    'country': {
        'code': 'BE', 
        'name': 'Belgium'
    }, 
    'status': 200
}

Response Fields

amount_excl_vat
Float
The amount excluding the VAT.
vat_amount
Float
The calculated amount of VAT.
amount_incl_vat
Float
The sum of the base amount and the VAT, i.e., amount_excl_vat + vat_amount.
vat_rate
Float
The VAT rate, from 0.01 to 0.99.
vat_category
String
The optional category of the purchase, used to determine whether it qualifies for a reduced rate. See below for a list of supported categories.
country_code
String
The two letter ISO 3166-1 alpha-2 code of the country in which the transaction takes place.
country_name
String
The name of the country the VAT is being calculated from.

Using optional arguments

Below is a code snippet on how to use optional arguments in the VatAPI.calculate() method:
from abstract_python import VatAPI

api_key = "your-vat-api-key"

api = VatAPI(api_key)
amount = "50"
country_code = "BE"
is_vat_incl = True
vat_category = "standard"
response = api.calculate(amount, country_code)

print(response)

Below is the response object:
{
    'amount_excluding_vat': '50.00', 
    'amount_including_vat': '60.50', 
    'vat_amount': '10.50', 
    'vat_category': 'standard', 
    'vat_rate': '0.210', 
    'country': {
        'code': 'BE', 
        'name': 'Belgium'
    }, 
    'status': 200
}