curatedapi

Discount calculator

Sale price after a percentage or fixed discount, an optional stacked second discount and sales tax.

Original price.
Discount in percent. Give this or discount_amount.
Discount as an amount. Give this or discount_percent.
Second discount applied to the already reduced price.
Sales tax added after the discounts.
More options: rounding and decimals
Precision and rounding
Rounding mode applied once to each result. Default half_even.
Round results to this many digits after the decimal point.

Examples

Result: 20% then an extra 10%

Discount amount
First discount.
20.00 exact
Additional discount amount
Second discount.
8.00 exact
Price after discount
Price after both discounts.
72.00 exact
Tax amount
Sales tax on the discounted price.
0.00 exact
Final price
Price after discounts plus tax.
72.00 exact
Total savings
Both discounts together.
28.00 exact
Effective discount percent
Total savings as a percent of the price. Unit: percent.
28.00 exact

Rounding: Half even, 2 decimal places. Calculator everyday/discount@1.

How it is calculated

after = price − d₁ − (price − d₁)·p₂; final = after + after·tax

Applies a discount (percent or amount), then an optional second percentage discount on the reduced price (the way '20% off, then an extra 10%' works in shops), then sales tax. Each money amount is rounded to the cent and the totals are built from those rounded amounts, so the figures always add up.

  • Amounts are plain numbers in any single currency; no currency conversion is done.

References

Results follow each calculator's documented rules and the sources listed. They are not financial, tax or legal advice. Check that the rules fit your case before you rely on a result. See the terms.

Use it from your code

POST /v1/calc/everyday/discountVersion 1
curl https://api.curatedapi.com/v1/calc/everyday/discount \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "price": "100",
    "discount_percent": "20",
    "additional_discount_percent": "10"
  }'
The same call in Python
import os

import requests

payload = {
    "price": "100",
    "discount_percent": "20",
    "additional_discount_percent": "10",
}
response = requests.post(
    "https://api.curatedapi.com/v1/calc/everyday/discount",
    headers={"Authorization": f"Bearer {os.environ['CURATEDAPI_KEY']}"},
    json=payload,
    timeout=10,
)
print(response.json()["result"])
The same call in JavaScript
const payload = {
    "price": "100",
    "discount_percent": "20",
    "additional_discount_percent": "10",
};
const response = await fetch("https://api.curatedapi.com/v1/calc/everyday/discount", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CURATEDAPI_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(payload),
});
console.log((await response.json()).result);

MCP tool calc_everyday_discount at https://mcp.curatedapi.com. Inputs, outputs and errors in the API reference.

Put it on your website

<div data-curatedapi-widget="everyday/discount" data-key="capi_public_…"></div>
<script src="https://widgets.curatedapi.com/v1/widget.js" async></script>

Use a public key registered for your site. Calculations are billed like API calls. How widgets work.

Related calculators

Add this calculator to your website

Paste two lines into your page and your visitors get this calculator. Each use counts as one call on your plan, the same as the API.

Free for up to 1,000 uses a month. 50,000 uses a month cost $9.00 on the Starter plan.