How to use
The Wealth Curve JS API is accessed through your browser’s Developer Tools console. With a model open in the app, open Dev Tools (e.g. F12 or right‑click → Inspect), go to the Console tab, and call window.wealthCurveModelAPI there. You can run any of the API methods from the console to read or modify the current model.
When is the API available? window.wealthCurveModelAPI is attached only when a model is open in the app (any tab: Overview, Income & Expenses, Projection, etc.). Use the console on the same origin as the app. If no model is open, the API is undefined.
Model info and data
getModelInfo()- Returns a summary object:
id,name,description,startYear,startAge,projectionYearCount,portfolioCount,expenseCount,incomeCount,overrideCount. getModelData()- Returns the full model form data (reactive store data). Use for reading all inputs.
// In the browser console with a model open:
window.wealthCurveModelAPI.getModelInfo()
// => { id: "...", name: "My Model", startYear: 2025, ... }
Year helpers
Years are stored as indices (0 = start year). Use these to convert:
getYearNumber(yearIndex)- Returns the calendar year for a given year index.
getYearIndex(yearNumber)- Returns the year index for a calendar year.
window.wealthCurveModelAPI.getYearNumber(0) // start year window.wealthCurveModelAPI.getYearIndex(2030) // index of year 2030
One-off expenses
getOneOffExpenses(yearIndex, isEducation = null)- Returns one-off expenses for that year. Pass
trueorfalseforisEducationto filter;nullreturns all. addOneOffExpense(yearIndex, description, amount, isEducation = false)- Adds a one-off expense and saves. Returns a Promise.
removeOneOffExpense(yearIndex, description, amount = null)- Removes the first matching expense;
amountoptional. Returns Promise resolving totrueif removed. removeOneOffExpenses(yearIndex = null, description = null, isEducation = null)- Removes all matching one-off expenses. Any argument
nullmeans “any”. Returns Promise resolving to count removed.
await window.wealthCurveModelAPI.addOneOffExpense(5, "Car purchase", 25000, false) const expenses = window.wealthCurveModelAPI.getOneOffExpenses(5)
One-off incomes
addOneOffIncome(yearIndex, description, amount)- Adds a one-off income and saves. Returns a Promise.
removeOneOffIncome(id)- Removes the one-off income with the given
idand saves. Returns a Promise.
Year overrides
Override income, expenses, portfolio values or other fields for a specific year.
getYearOverride(yearIndex)- Returns the override object for that year or
null. setYearOverride(yearIndex, overrideData)- Sets override data for the year (e.g.
{ monthlyExpenses: 5000 }) and saves. Returns a Promise. removeYearOverride(yearIndex)- Removes the override for that year and saves. Returns a Promise.
await window.wealthCurveModelAPI.setYearOverride(3, { monthlyExpenses: 4500 })
Portfolios
getPortfolio(index)- Returns the portfolio at the given index (0-based) or
null. updatePortfolio(index, updates)- Merges
updatesinto the portfolio atindexand saves. Returns a Promise. Example:{ balance: 100000, cagr: 0.06 }.
Save
save()- Persists the current model to storage (local or cloud). Returns a Promise. Call after making direct changes to data if you bypass other API methods.
Advanced
getStore()- Returns the underlying Pinia model store for advanced usage.