
Sales Tax Calculator API
Add or remove GST, HST, PST or QST for any Canadian province, or a US or custom rate, with each tax shown separately and reverse results that are exact to the cent.
Send your API key as a Bearer token in the Authorization header (Authorization: Bearer YOUR_API_KEY), or in an X-API-Key header.
120 requests per minute
1 endpoint available
Overview
Works out sales tax both ways. mode: "add" takes a price before tax and returns each tax and the total. mode: "remove" takes a total that includes tax and returns the price before tax.
Where
region: a Canadian province or territory code (AB, BC, MB, NB, NL, NS, NT, NU, ON, PE, QC, SK, YT). Rates are GST, HST, PST, QST or RST as that region charges them. Rates were checked on 2026-11-25. Check them for anything that matters.rates: your own list of 1 to 4 taxes, each{ "name": "State", "rate": 6.25 }. Use one entry for a combined US state and local rate. Rates are percentages from 0 to 100 with at most 4 decimal places.- Send one of the two, not both.
Rounding
- Each tax is rounded to the cent on its own, half up, the way a receipt shows GST and PST or QST separately. Rates are handled as exact scaled integers, with no floating-point drift.
singleStepTaxis the tax if the combined rate were applied once and rounded once. It can differ fromtaxby a cent.- Quantity times unit price: instead of
amount, anaddrequest can sendquantity(up to 3 decimals) andunitPrice. The line total is rounded half up to the cent.
Remove mode
The price before tax is found by search, so taxing it forward gives back your total exactly. Some totals cannot be produced by any price once each tax is rounded. Then exact is false and you get nearestBelow, nearestAbove and a split of the total by the combined rate.
All amounts are numbers in dollars. Amounts up to 10 billion.
Endpoints
https://opentools.ca/api/v1/tools/sales-tax-calculatorRequest Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| mode | string Enum: add, remove | Optional | Add tax to a price, or remove it from a total.Default: add |
| amount | number | Optional | The price before tax (add) or the total including tax (remove). |
| quantity | number | Optional | add only. Use with unitPrice instead of amount. Up to 3 decimals. |
| unitPrice | number | Optional | add only. Price of one unit. Use with quantity. |
| region | string Enum: AB, BC, MB, NB, NL, NS, NT, NU, ON, PE, QC, SK, YT | Optional | Canadian province or territory code. |
| rates | array | Optional | Your own taxes, 1 to 4. Use instead of region. |
| rates[].name | string | Optional | Tax name.Default: Sales tax |
| rates[].rate | number | Required | Percentage, 0 to 100, up to 4 decimal places. |
Response Example
{
"success": true,
"mode": "add",
"region": "ON",
"regionName": "Ontario",
"combinedRate": 13,
"beforeTax": 100,
"taxes": [
{
"name": "HST",
"rate": 13,
"amount": 13
}
],
"tax": 13,
"total": 113,
"singleStepTax": 13
}Error Codes
Code Examples
# Add Ontario HST to a price
curl -X POST https://opentools.ca/api/v1/tools/sales-tax-calculator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"mode": "add",
"amount": 100,
"region": "ON"
}'
# Remove a US combined rate from a total
curl -X POST https://opentools.ca/api/v1/tools/sales-tax-calculator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"mode": "remove",
"amount": 108.25,
"rates": [
{
"name": "Sales tax",
"rate": 8.25
}
]
}'Rather use it in your browser? Open the Sales Tax Calculator