> ## Documentation Index
> Fetch the complete documentation index at: https://rilwanorganization.mintlify.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Calculate VAT.

> This endpoint allows you to calculate VAT on the prices of goods in a particular country.

## 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:

<ParamField path="amount" type="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
</ParamField>

<ParamField path="country_code" type="String" required>
  The two letter ISO 3166-1 alpha-2 code of the country in which the transaction takes place.
</ParamField>

<ParamField path="is_vat_incl" type="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.
</ParamField>

<ParamField path="vat_category" type="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.
</ParamField>

## Usage

Below is a code snippet to query the `VatAPI.calculate()` method:

```python theme={null}
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

<ResponseField name="amount_excl_vat" type="Float">
  The amount excluding the VAT.
</ResponseField>

<ResponseField name="vat_amount" type="Float">
  The calculated amount of VAT.
</ResponseField>

<ResponseField name="amount_incl_vat" type="Float">
  The sum of the base amount and the VAT, i.e., `amount_excl_vat` + `vat_amount`.
</ResponseField>

<ResponseField name="vat_rate" type="Float">
  The VAT rate, from 0.01 to 0.99.
</ResponseField>

<ResponseField name="vat_category" type="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.
</ResponseField>

<ResponseField name="country_code" type="String">
  The two letter ISO 3166-1 alpha-2 code of the country in which the transaction takes place.
</ResponseField>

<ResponseField name="country_name" type="String">
  The name of the country the VAT is being calculated from.
</ResponseField>

## Using optional arguments

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

```python theme={null}
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
}
```
