DEV Community

Daniel Igel
Daniel Igel

Posted on

Mortgage, loan and compound interest calculations via REST API — no spreadsheet needed

Building financial calculators means re-implementing the same amortization formulas in every project. The Financial Calculator API handles loan payments, mortgage amortization, compound interest, savings goals, and ROI via plain POST requests — no spreadsheet embedded in your backend.

POST /api/v1/loan takes principal, annualRate (as a percentage, e.g. 6.5), and months, and returns a monthly payment, total interest, and a full amortization schedule:

curl --request POST \
  --url 'https://financial-calculator-api2.p.rapidapi.com/api/v1/loan' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --header 'x-rapidapi-host: financial-calculator-api2.p.rapidapi.com' \
  --header 'content-type: application/json' \
  --data '{"principal": 20000, "annualRate": 6.5, "months": 48}'
Enter fullscreen mode Exit fullscreen mode

Response includes monthlyPayment: 474.3, totalInterest: 2766.36, and a schedule array with per-month payment, principal, interest, and remaining balance.

const res = await fetch(
  'https://financial-calculator-api2.p.rapidapi.com/api/v1/loan',
  {
    method: 'POST',
    headers: {
      'x-rapidapi-key': process.env.RAPIDAPI_KEY,
      'x-rapidapi-host': 'financial-calculator-api2.p.rapidapi.com',
      'content-type': 'application/json',
    },
    body: JSON.stringify({ principal: 20000, annualRate: 6.5, months: 48 }),
  }
);
const { monthlyPayment, totalInterest, schedule } = await res.json();
Enter fullscreen mode Exit fullscreen mode

For mortgages, POST /api/v1/mortgage adds an optional extraPayments array — pass [{ "month": 12, "amount": 1000 }] and the response includes interestSavings showing exactly how much a lump-sum prepayment saves over the loan term.

Need compound growth or savings goal projections? /api/v1/compound and /api/v1/savings cover those; /api/v1/roi computes return on investment and — with an optional years field — CAGR. All five calculators are pure JS, zero external dependencies.

Free tier on RapidAPI: https://rapidapi.com/danieligel/api/financial-calculator-api2

Do you compute financial projections client-side or delegate the math to an API?

Top comments (0)