The /finance namespace covers four distinct data domains: stock quotes, forex exchange rates, loan EMI calculation, and cryptocurrency prices. Each required a different approach to data sourcing, API shape normalisation, and reliability strategy.
Stock quotes — Yahoo Finance (unofficial)
Yahoo Finance doesn't have an official public API, but theirquery1.finance.yahoo.com/v8/finance/chart/{symbol} endpoint has been stable and widely used. We fetch from it server-side on every request — no caching yet.
The response normalisation is the interesting part. Yahoo returns a deeply nested structure with chart.result[0].meta containing price, previous close, currency, and exchange. We flatten this into a clean shape: { symbol, price, change, change_pct, currency, exchange, market_state }.
Why Yahoo and not Alpha Vantage or Twelve Data? Both require API keys with restrictive free tiers. Yahoo's unofficial endpoint is free, has no key requirement, and covers global exchanges including NSE/BSE. For an API platform where our users pay us — not a third provider — keeping upstream dependencies key-free is a hard requirement.
Forex rates — ECB via Frankfurter
api.frankfurter.appproxies the European Central Bank's reference rates. It's open, free, no key required, and covers 30+ currencies updated daily. For our use case — providing exchange rates to developers — this is exactly right.
We support both single-pair queries (?from=USD&to=INR) and base-currency queries that return all available pairs. The Frankfurter response maps directly to our envelope with minimal transformation.
EMI Calculator — standard amortisation formula
No external dependency. Pure math. The EMI formula is:
EMI = P × r × (1+r)^n / ((1+r)^n - 1)
where:
P = principal loan amount
r = monthly interest rate (annual_rate / 100 / 12)
n = number of monthly instalmentsWe return the full amortisation summary: EMI, total payment, total interest, and interest as a percentage of the loan. No rounding surprises — we compute with full floating point precision and only round the final output fields.
Crypto prices — Yahoo Finance (BTC-USD ticker format)
Same Yahoo Finance endpoint, but with tickers like BTC-USD, ETH-USD, SOL-USD. Yahoo Finance covers all major cryptocurrencies in this format. The normalisation is identical to the equities path — we reuse the same extraction function.
Response shape decisions
Every finance endpoint returns amounts in the currency of the underlying data source. We pass the currency code explicitly in the response. Developers who need currency conversion can chain a call to /currency/convert. This keeps each endpoint single-purpose rather than building a multi-step pipeline internally.
What's next for /finance
Caching is the obvious improvement. A 5-minute cache on stock quotes would dramatically reduce upstream request volume without meaningfully degrading data freshness for most use cases. Rate limiting per symbol (to prevent single-symbol hammering) is also on the list. Historical price data is the most-requested feature.