Financial Math API
POST /api/calc/finance $0.005 per call
USDC on Base · x402
Exact financial + token math. POST {op:…}: compound (growth with per-period contributions), amortize (payment, total interest, schedule), npv, irr (deterministic bisection) — and token_units: exact decimal↔base-unit conversion via BigInt for any token decimals (ETH 18, USDC 6), the 18-decimal math that float64 silently corrupts. Iterative series computed exactly, never guessed.
Parameters
| Name | In | Description | |
|---|---|---|---|
op | body | required | compound | amortize | npv | irr | token_units |
principal | body | ||
rate | body | annual %, e.g. 6.5 | |
years | body | ||
periods_per_year | body | default 12 | |
contribution_per_period | body | ||
cashflows | body | npv/irr — period 0 first | |
amount | body | token_units — decimal or base-unit string | |
decimals | body | token_units — ETH 18, USDC 6 | |
to | body | token_units — base | decimal |
Example request
curl -X POST "https://api.webbersites.com/api/calc/finance" \
-H "Content-Type: application/json" \
-d '{"op":"amortize","principal":300000,"rate":6.5,"years":30}'
# first call returns 402 + payment requirements; an x402 client pays and retries automaticallyExample response
{
"op": "amortize",
"payment_per_period": 1896.2,
"periods": 360,
"total_interest": 382633.47
}MCP tool: post_calc_finance — via npx -y webbersites-x402-mcp (local, key stays on your machine) or the remote endpoint https://api.webbersites.com/mcp.
How payment works
There is no signup and no API key. Call the endpoint; it replies 402 Payment Required with machine-readable payment requirements. Your client signs a USDC transfer authorization (EIP-3009, gasless) and retries with the X-PAYMENT header — @x402/fetch does this automatically. See the overview for a working snippet.