Skip to main content

Developer API · v1

Compound Interest API

Free, edge-cached JSON endpoints for compound interest and FIRE math — the same library that powers our calculators. No API key, CORS-enabled, cached at the edge.

Overview

All endpoints are GET requests that return JSON. They are deterministic and cached at the Cloudflare edge, require no authentication, and send Access-Control-Allow-Origin: * so you can call them from the browser, a spreadsheet, or a server. Base URL: https://interestcompound.com/api/v1.

GET /compound

Period-by-period compound interest with optional recurring contributions.

https://interestcompound.com/api/v1/compound?principal=10000&rate=7&years=10&frequency=12&contribution=100
ParamRequiredDescription
principal yes Starting amount (0–1e12).
rate yes Annual interest rate in percent (0–100).
years yes Number of years (1–200).
frequency no Compounding periods/yr: a number 1–365 or a label (daily, monthly, quarterly, annually). Default 12.
contribution no Recurring contribution amount. Default 0.
contributionFrequency no Contributions per year. Default 12.
timing no "begin" or "end" of period. Default "end".

Example response

{
  "inputs": { "principal": 10000, "rate": 7, "years": 10, "frequency": 12,
              "contribution": 100, "contributionFrequency": 12, "timing": "end" },
  "result": {
    "finalBalance": 37405.09,
    "totalContributions": 22000,
    "totalInterest": 15405.09
  },
  "yearly": [ { "year": 1, "endBalance": 11962.16, "interest": 762.16, "contributions": 1200 } ],
  "meta": { "currency": "USD", "source": "https://interestcompound.com" }
}

GET /fire

FIRE number, Coast FIRE number, and years-to-FIRE.

https://interestcompound.com/api/v1/fire?annualSpending=40000&swr=4&currentInvested=100000&annualContribution=20000&return=7&yearsToRetirement=20
ParamRequiredDescription
annualSpending yes Target annual spending in retirement.
swr no Safe withdrawal rate in percent. Default 4.
currentInvested no Amount invested today. Default 0.
annualContribution no Yearly contribution. Default 0.
return no Expected annual return in percent. Default 7.
yearsToRetirement no Years until retirement (for Coast FIRE). Default 0.

Example response

{
  "inputs": { "annualSpending": 40000, "swr": 4, "currentInvested": 100000,
              "annualContribution": 20000, "return": 7, "yearsToRetirement": 20 },
  "result": {
    "fireNumber": 1000000,
    "coastFireNumber": 258419.0,
    "alreadyCoastFire": false,
    "yearsToFire": 18,
    "reachesFire": true
  },
  "meta": { "currency": "USD", "source": "https://interestcompound.com" }
}

Errors

Invalid parameters return 400 with { "error": "..." }. Responses are cached (Cache-Control: public) — 24h for success, 60s for errors.