curatedapi
Browse the docs

Guides

Finance

Excel functions

Late payments

E-invoices

Accounting

Number checks

VAT and GST

Billing and pricing

Money and currencies

Dates and time

Math

Unit conversion

Everyday

Health

Percentage API

Percent of a number, what percent one number is of another, percent change, percent difference, and increase or decrease by a percent.

POST https://api.curatedapi.com/v1/calc/math/percentage

Six everyday percentage questions in one calculator, each with its formula returned so the meaning of a and b is never in doubt. All arithmetic is exact.

Formula

see formula_used
  • Percent change divides by |a|, so a change from -50 to -25 is +50% (an increase).
  • Percent difference compares two values symmetrically, using their average magnitude as the base.

Inputs

Send numbers as strings to keep every digit. options sets precision and rounding (see numbers and rounding).

InputTypeDescription
operation required percent_of | what_percent | change | difference | increase | decrease Which percentage question to answer. Options: percent_of: a% of b; what_percent: a is what percent of b; change: percent change from a to b; difference: percent difference between a and b; increase: b increased by a%; decrease: b decreased by a%
a required decimal (string) First number (see operation for its meaning).
b required decimal (string) Second number (see operation for its meaning).
options.rounding half_even | half_up | half_down | up | down | ceiling | floor Rounding mode applied once to each result. Default half_even.
options.decimals integer Round results to this many digits after the decimal point.
options.significant_digits integer Round results to this many significant digits.

Result

Under result in the answer, next to exactness, precision, inputs, formula, references and warnings.

ResultTypeDescription
resultdecimal (string)The answer (a percentage for what_percent, change and difference).
formula_usedstringThe formula applied.

Examples

15% of 80

Requestcurl
curl https://api.curatedapi.com/v1/calc/math/percentage \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "percent_of",
    "a": "15",
    "b": "80"
  }'
200 OKResponse
{
  "calculator": "math/percentage@1",
  "result": {
    "result": "12",
    "formula_used": "a / 100 × b"
  },
  "exactness": {
    "result": "exact"
  },
  "precision": {
    "rounding": "half_even",
    "significant_digits": 15
  },
  "inputs": {
    "operation": "percent_of",
    "a": "15",
    "b": "80"
  },
  "formula": "see formula_used",
  "references": [
    {
      "title": "Percentage",
      "url": "https://en.wikipedia.org/wiki/Percentage"
    },
    {
      "title": "Relative change and percent difference",
      "url": "https://en.wikipedia.org/wiki/Relative_change"
    }
  ],
  "warnings": []
}

Change from 80 to 100

Requestcurl
curl https://api.curatedapi.com/v1/calc/math/percentage \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "change",
    "a": "80",
    "b": "100"
  }'
200 OKResponse
{
  "calculator": "math/percentage@1",
  "result": {
    "result": "25",
    "formula_used": "(b − a) / |a| × 100"
  },
  "exactness": {
    "result": "exact"
  },
  "precision": {
    "rounding": "half_even",
    "significant_digits": 15
  },
  "inputs": {
    "operation": "change",
    "a": "80",
    "b": "100"
  },
  "formula": "see formula_used",
  "references": [
    {
      "title": "Percentage",
      "url": "https://en.wikipedia.org/wiki/Percentage"
    },
    {
      "title": "Relative change and percent difference",
      "url": "https://en.wikipedia.org/wiki/Relative_change"
    }
  ],
  "warnings": []
}

1 is what percent of 3

Requestcurl
curl https://api.curatedapi.com/v1/calc/math/percentage \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "what_percent",
    "a": "1",
    "b": "3"
  }'
200 OKResponse
{
  "calculator": "math/percentage@1",
  "result": {
    "result": "33.3333333333333",
    "formula_used": "a / b × 100"
  },
  "exactness": {
    "result": "rounded"
  },
  "precision": {
    "rounding": "half_even",
    "significant_digits": 15
  },
  "inputs": {
    "operation": "what_percent",
    "a": "1",
    "b": "3"
  },
  "formula": "see formula_used",
  "references": [
    {
      "title": "Percentage",
      "url": "https://en.wikipedia.org/wiki/Percentage"
    },
    {
      "title": "Relative change and percent difference",
      "url": "https://en.wikipedia.org/wiki/Relative_change"
    }
  ],
  "warnings": []
}

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.

Errors share one format; see errors. Billing, retries and batches work the same for every endpoint.