Skip to content

Using exchange rates in an app

4 min read API guides

exchange rates in an app

To use exchange rates in an app, treat the number and its timestamp as one value. An exchange rate is a number with a timestamp. A table without a time is hard to trust. A checkout that uses yesterday’s rate can charge the wrong amount. The age of the rate and the refresh schedule matter as much as the number.

The Exchange rate endpoint returns currency data with an optional base and quote conversion.

curl "https://api2.globus.studio/v2/currencies?base=USD&quote=EUR&format=json"

The table response

Without quote the endpoint returns the table: currency codes, the base currency, the date, and buy and sell rates. The default base is UAH. format=raw returns the original payload when you need every field.

A single pair

With base and quote the response becomes one object with base, quote, rate and updated_at. The rate is derived from the table. Check the timestamp before you use it in a price.

{
  "base": "USD",
  "quote": "EUR",
  "rate": 1.12195,
  "updated_at": "2026-11-02T09:16:13+00:00"
}

Refresh exchange rates in an app

The endpoint reads a file written by a scheduled job. It does not call the provider on every request. Cache the response for a few minutes. If the timestamp is older than your policy allows, show a warning or fall back to your own rate.

Rounding

Exchange rates in an app can change between the page and the charge, so do not round in the middle of a calculation. Keep the full rate, multiply, then round to the currency’s minor unit. Store the rate and the timestamp with the order so you can explain the amount later.

What it is not

This is not a trading feed and not a guarantee. The reference rate can differ from the rate a bank or a payment provider uses for a charge. Use the API for display and estimates, and the provider’s rate for the final charge.

Limits

Exchange rates in an app should come from a cached response, not a fresh call on every page view. The endpoint is fast and rate limited. Read the endpoint documentation for parameters and examples.

Invoices and rounding

Store the rate, the source timestamp and the final amount with the invoice. If a customer questions the total, you can show how it was calculated. Round only the final amount, and use the currency’s minor unit. A rate rounded to two decimals before multiplication can shift a large total.

Stale data

Set a maximum age for the rate. If the timestamp is older than that, show the last known value with a warning or use a manual rate. A checkout should not fail because a data file is a few minutes late. It also should not charge with a rate from last week. Store the age policy with the code so the rule is visible in a review.

If the feed is slow, the page can still show a price with a note and a timestamp. A customer who sees the time understands why the total changed between two visits. A page that hides the time invites a support ticket.

$rate = $data['rate'];
$total = round($amount * $rate, 2);

Read the documentation for the table and pair responses.

Weekends and holidays

Currency markets close, and a published rate can stay unchanged for a day or two. That is not a broken feed, and the age of the rate is part of the answer. Check the timestamp before you show a "live" label. For an invoice, use the rate and the time you actually applied, not the time the page was rendered.

A scheduled refresh keeps the file current. If the job fails, the endpoint keeps serving the last file. Monitor the age of the file and alert when it passes your limit.

Related reading

Exchange rates in an app need a timestamp next to the amount. For the request that starts a checkout, see getting a visitor IP address. For a broader view of how we keep contracts small, read why small APIs beat one big integration.

Further reading: ISO 4217 currency codes.

Custom work

Need an API that does not exist yet?

Describe the task and the response format. We will estimate the endpoint, the integration and the maintenance.

Start a conversation