---
title: "Exact financial + token math"
method: POST
path: "/api/calc/finance"
tags: ["Math"]
---

# Exact financial + token math

`POST /api/calc/finance`

## Request

- Base URL: `https://api.webbersites.com`
- URL: `https://api.webbersites.com/api/calc/finance`
- Auth: API key in header `X-PAYMENT`

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.

Price: $0.005 per call, paid in USDC via the x402 protocol (see the x402 security scheme).

## Request body

- object
  - `op` string, required: compound | amortize | npv | irr | token_units
  - `principal` number
  - `rate` number: annual %, e.g. 6.5
  - `years` number
  - `periods_per_year` number: default 12
  - `contribution_per_period` number
  - `cashflows` unknown[]: npv/irr — period 0 first
    - unknown
  - `amount` string: token_units — decimal or base-unit string
  - `decimals` number: token_units — ETH 18, USDC 6
  - `to` string: token_units — base | decimal

## Response `200`

Success

- object
  - `op` string
  - `future_value` number
  - `payment_per_period` number
  - `total_interest` number
  - `schedule` unknown[]
    - unknown
  - `npv` number
  - `irr_pct` number
  - `base_units` string
  - `decimal` string

## Other responses

- `402`: Payment required — the response body lists accepted payment methods (amount, asset, network, pay-to address). Retry the request with a signed X-PAYMENT header.

---

[API](https://skmtc.dev/webbersites/apis/webbersites-x402-data-api.md) · [All operations](https://skmtc.dev/webbersites/apis/webbersites-x402-data-api/llms.txt) · [OpenAPI document](https://skmtc.dev/webbersites/apis/webbersites-x402-data-api/revisions/c14a76c67a94?raw)
