Sales Tax Calculator

Sales Tax Calculator API

Finance

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.

Authentication

Send your API key as a Bearer token in the Authorization header (Authorization: Bearer YOUR_API_KEY), or in an X-API-Key header.

Rate Limit

120 requests per minute

Endpoints

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.
  • singleStepTax is the tax if the combined rate were applied once and rounded once. It can differ from tax by a cent.
  • Quantity times unit price: instead of amount, an add request can send quantity (up to 3 decimals) and unitPrice. 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

POST
https://opentools.ca/api/v1/tools/sales-tax-calculator
Add sales tax to a price, or take it out of a total

Request Body

Content-Type: application/json

ParameterTypeRequiredDescription
mode
string
Enum: add, remove
OptionalAdd tax to a price, or remove it from a total.Default: add
amount
number
OptionalThe price before tax (add) or the total including tax (remove).
quantity
number
Optionaladd only. Use with unitPrice instead of amount. Up to 3 decimals.
unitPrice
number
Optionaladd only. Price of one unit. Use with quantity.
region
string
Enum: AB, BC, MB, NB, NL, NS, NT, NU, ON, PE, QC, SK, YT
OptionalCanadian province or territory code.
rates
array
OptionalYour own taxes, 1 to 4. Use instead of region.
rates[].name
string
OptionalTax 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

400
Bad Request - Neither or both of region and rates given, a rate has too many decimals, or the amount fields do not fit the mode
401
Unauthorized - Missing or invalid API key
403
Forbidden - The API key is inactive or expired, or the request IP is not allowed
405
Method Not Allowed - This endpoint accepts POST only
429
Too Many Requests - Rate limit exceeded (120 requests per minute per API key)
500
Internal Server Error

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
    }
  ]
}'

Ready to get started?

Create an API key to start using the Sales Tax Calculator API.

Rather use it in your browser? Open the Sales Tax Calculator