Building a currency converter

A currency converter is a multiplication and a rate, so the whole job is the rate: which of the three prices you use, how recently it was read, and what the screen says when the source that supplies it stops answering.

The arithmetic is one line. Everything that makes a converter right or wrong is the number you multiply by, and where it came from.

Add as a preferred source on Google

The version that looks finished in ten minutes

Fetch a rate once, multiply, print. It works, it demos perfectly, and it is wrong from the moment the rate moves. The failure is quiet, because a converter showing a number from this morning looks exactly like one showing a number from this second. Nobody can tell by looking, which is why this is worth more care than the amount of code suggests.

Three prices, and the one people quote

A currency pair has a bid, an ask, and a mid halfway between. The mid is the number in headlines and the number nobody trades at. If your converter is answering what is this worth, the mid is right. If it is answering what will I actually receive, the mid is optimistic by half the spread before anybody has charged a fee, and a converter that does not say which question it is answering is answering neither.

Where the rate comes from, and what that costs

Free rate feeds mostly update once a day, which is fine for a price list and misleading in a converter that implies live. Market feeds update continuously and rate limit you instead. Neither is wrong; they answer different questions. Pick based on what your users will do with the number, and say in the interface which one you chose, because the difference between a daily reference rate and a live one is invisible in the output and enormous in a volatile hour.

Refresh policy is a product decision, not a technical one

A converter that refreshes on every keystroke is expensive and jumpy, and one that refreshes hourly is stale in a fast market. The useful middle is to read on open, read again when the user changes a currency, and show the read time so somebody about to move real money can see the age of the number. That last part costs one line and is the difference between a tool and a toy.

What to show when the rate feed is down

The temptation is to keep the last number on screen, because the page looks broken without it. That is the worst option: a stale rate presented as current is how somebody converts at a number that no longer exists. Show what you know, say when you read it, and if it is too old to trust, say that instead of a figure. A converter that admits it cannot see the market is more useful than one that guesses.

What you can read here without a key

Bid, ask and spread on four currency pairs, from a live market, with no credentials. Our own page for those rates is linked below and shows the same figures this relay would give your app, alongside what each one is and is not. The table under this section is a different feed answering while the page was served.

Live, right now, on this page

MarketPriceFunding24h volume
BTC$86,364.500.0013%$522,866,341
ETH$2,750.850.0013%$301,603,802
SOL$118.010.0013%$94,709,358
HYPE$96.970.0013%$3,938,323

Read from a live market as this page rendered, through the same keyless relay a converter would call. Read at 2026-09-23 02:12 UTC; accurate as of that time and not afterwards.

Describe something and watch it get built.

Open the builder, or start from a working app and change it.

Common questions

Where can I get live exchange rates for free?

Free feeds exist and most of them update once a day, which is enough for a price list and misleading inside anything that implies live. Market data feeds update continuously and limit how often you may call them. The honest move is to pick one deliberately and tell the user which, because a daily rate and a live rate look identical on screen.

Why does my converter disagree with what my bank charges?

Because you are almost certainly showing the mid rate, halfway between what buyers and sellers are quoting, and nobody transacts at the mid. A bank quotes you one side of that spread plus a margin for holding and hedging the currency. The gap is not evidence of anything dishonest on its own; what matters is whether the provider states it or buries it in a worse rate.

How often should a currency converter refresh its rate?

On open, again when the user changes either currency, and otherwise no faster than the market moves enough to matter for the amounts involved. Refreshing on every keystroke costs money and makes the figure jump while somebody is reading it. Whatever you choose, show the time the rate was read, so a person moving real money can see how old the number is.

See the number itself

Pages that read a live market and show what they read, updated while you look at them.

Related reading

All guides · Live market pages · Components · Make Mithril a preferred source in Google