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

Excel NPER function: number of periods API

How many periods it takes to pay off a loan or reach a goal, as Excel's NPER.

POST https://api.curatedapi.com/v1/calc/excel/nper

NPER(rate, pmt, pv, [fv], [type]).

Formula

NPER = ln((pmt·(1+rate·type) − fv·rate) / (pmt·(1+rate·type) + pv·rate)) / ln(1+rate)
  • Arguments are named and ordered as in Excel. Excel computes in binary floating point; this API computes the exact value of the same formula and rounds it once, so it agrees with Excel to the digits Excel can show, and where Excel's own rounding error reaches the 15th digit this answer is the correct one.

Inputs

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

InputTypeDescription
rate required decimal (string) Interest rate per period, as a decimal (0.005 for 0.5%). Write a monthly rate from an annual one as "0.06/12". A ratio of two decimals such as "0.08/12" is accepted. Allowed: > -1 and <= 1000.
pmt required decimal (string) Payment made each period. A ratio of two decimals such as "0.08/12" is accepted. Allowed: >= -1000000000000000 and <= 1000000000000000.
pv required decimal (string) Present value. A ratio of two decimals such as "0.08/12" is accepted. Allowed: >= -1000000000000000 and <= 1000000000000000.
fv decimal (string)
default 0
Future value wanted. A ratio of two decimals such as "0.08/12" is accepted. Allowed: >= -1000000000000000 and <= 1000000000000000.
type integer
default 0
When payments are due: 0 at the end of each period, 1 at the beginning. Allowed: >= 0 and <= 1.
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
nperdecimal (string)The number of periods (not rounded to whole periods).

Examples

Microsoft's example: payments at the start of each period

Requestcurl
curl https://api.curatedapi.com/v1/calc/excel/nper \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "rate": "0.12/12",
    "pmt": "-100",
    "pv": "-1000",
    "fv": "10000",
    "type": 1,
    "options": {"significant_digits": 9}
  }'
200 OKResponse
{
  "calculator": "excel/nper@1",
  "result": {
    "nper": "59.6738657"
  },
  "exactness": {
    "nper": "rounded"
  },
  "precision": {
    "rounding": "half_even",
    "significant_digits": 9
  },
  "inputs": {
    "rate": "0.01",
    "pmt": "-100",
    "pv": "-1000",
    "fv": "10000",
    "type": 1
  },
  "formula": "NPER = ln((pmt·(1+rate·type) − fv·rate) / (pmt·(1+rate·type) + pv·rate)) / ln(1+rate)",
  "references": [
    {
      "title": "Microsoft Excel NPER function",
      "url": "https://support.microsoft.com/en-us/excel/functions/nper-function"
    }
  ],
  "warnings": []
}

Microsoft's example: payments at the end of each period

Requestcurl
curl https://api.curatedapi.com/v1/calc/excel/nper \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "rate": "0.12/12",
    "pmt": "-100",
    "pv": "-1000",
    "fv": "10000",
    "options": {"significant_digits": 9}
  }'
200 OKResponse
{
  "calculator": "excel/nper@1",
  "result": {
    "nper": "60.0821229"
  },
  "exactness": {
    "nper": "rounded"
  },
  "precision": {
    "rounding": "half_even",
    "significant_digits": 9
  },
  "inputs": {
    "rate": "0.01",
    "pmt": "-100",
    "pv": "-1000",
    "fv": "10000",
    "type": 0
  },
  "formula": "NPER = ln((pmt·(1+rate·type) − fv·rate) / (pmt·(1+rate·type) + pv·rate)) / ln(1+rate)",
  "references": [
    {
      "title": "Microsoft Excel NPER function",
      "url": "https://support.microsoft.com/en-us/excel/functions/nper-function"
    }
  ],
  "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.