Get Multiple Exchange Rates in One API Call (and Stop Wasting Requests)

6 min read

Get Multiple Exchange Rates in One API Call (and Stop Wasting Requests)

If you need to get multiple exchange rates at once, do not loop over currencies and call a "single pair" endpoint for each one. Most rate APIs let you request several quote currencies against one base in a single call. That cuts latency, request volume and the number of places where something can fail.

This article explains when batching helps, how to do it with GetRatesAPI (up to 20 quotes per call, still one request unit), how to split longer lists, and how to turn the results into correct prices without floating-point drift.

Why one request per currency does not scale

Imagine a product page that shows a price in 12 currencies. A naive implementation calls EUR/USD, EUR/GBP, EUR/JPY and so on, one request each. That has four costs:

  • Latency. Twelve round trips, even in parallel, are slower than one. The page waits for the slowest.
  • Quota. If every call is billed, 12 calls burn 12 units where one would do. Multiply by every page view that misses your cache.
  • Rate limits. A burst of parallel calls is the classic way to hit a per-second limit. See how to handle 429 errors and retries for what to do when that happens.
  • Inconsistent snapshots. Twelve calls made over a second or two can return observations taken at slightly different moments. For a price list, that is rarely harmful, but for a dashboard comparing currencies it is untidy.

The same shape shows up in many places: currency pickers that preview a rate for each option, treasury dashboards that show one reporting currency against a dozen others, invoicing screens that list "amount in your currency" for several currencies, and nightly jobs that refresh a local table.

The batch pattern: one base, many quotes

The idea is simple: pick one base currency and ask for a list of quote currencies. With GetRatesAPI that is:

curl "https://api.getratesapi.com/v1/rates/EUR?quote=USD,GBP,JPY,CHF,CAD" \
  -H "Authorization: ApiKey $GETRATESAPI_KEY"

Key facts about this endpoint:

  • Up to 20 quotes per call.
  • The call costs 1 request unit, no matter how many quotes you ask for.
  • Quotes the API cannot serve are listed in an unsupported field instead of failing the whole call. One typo or delisted code does not take down your page.
  • Each rate carries its own as_of, status (fresh or stale) and type (direct or derived), exactly like the single-pair endpoint. A single rate looks like this:
{"base":"EUR","quote":"USD","rate":"1.0842","as_of":"2026-01-02T10:00:00Z","status":"fresh","type":"direct"}

Check the current rate documentation for the exact layout of the multi-quote response. Rates and amounts are JSON strings, so nothing is rounded or turned into a float on the way to your code.

What "one base" means for your design

A batch is one base against many quotes. If your dashboard needs several different bases, you need one call per base. Usually you can avoid that by choosing a single reporting or pricing currency. Because any pair works even when no market quotes it directly (missing pairs are derived through USD, EUR or BTC), you are free to choose the base that makes sense for your product rather than the one a data source happens to list. If you want to understand what derived means in practice, see cross rates explained.

Handling lists longer than 20

Sometimes you have 45 currencies. Split them into chunks of 20, deduplicate first, and run the chunks one after another. That is 3 calls (20 + 20 + 5), so 3 units.

Here is a small JavaScript helper (Node 18+, which has fetch built in):

const BASE_URL = "https://api.getratesapi.com";

function chunk(items, size) {
  const out = [];
  for (let i = 0; i < items.length; i += size) {
    out.push(items.slice(i, i + size));
  }
  return out;
}

export async function fetchRates(base, quotes) {
  const unique = [...new Set(quotes.map((q) => q.trim().toUpperCase()))]
    .filter((q) => q !== base);
  const responses = [];

  // Sequential on purpose: it stays well under per-second rate limits.
  for (const group of chunk(unique, 20)) {
    const url = `${BASE_URL}/v1/rates/${base}?quote=${group.join(",")}`;
    const res = await fetch(url, {
      headers: { Authorization: `ApiKey ${process.env.GETRATESAPI_KEY}` },
    });

    if (!res.ok) {
      const err = await res.json();
      // Match on err.code only; the message text can change.
      throw new Error(`${err.code} (request_id ${err.request_id})`);
    }
    responses.push(await res.json());
  }
  return responses;
}

A few choices worth copying:

  1. Normalize input. Trim, uppercase and deduplicate. Cheap, and it prevents invalid_asset_symbol errors from sloppy config.
  2. Remove the base from the quotes. Asking for EUR against EUR is wasted space.
  3. Go sequential for big lists. A handful of calls in a row is fast enough, and it keeps you inside the per-second limit of your plan. If you do need concurrency, cap it and honor retry_after_seconds on a rate_limit_exceeded (429) response, as described in the rate limit docs.
  4. Match on code, not message. Errors are JSON with code, message and request_id. Log the request_id; it is what support will ask for.

Treat the response as data you must inspect

Batching makes it easy to forget that each rate is its own observation. Before you use the results, check three things.

Unsupported quotes. Anything in unsupported should be handled deliberately: hide that currency in the UI, fall back to a default, or alert yourself if it was a code you expected to work. You can validate your list up front with the free catalog endpoints (/v1/assets, /v1/assets/fiat, /v1/assets/crypto), which are not billed. See the assets documentation or the full currency list.

Status. stale means the observation is older than the freshness window (1 minute for crypto, 5 minutes for fiat). Stale rates are flagged, not withheld, so the decision is yours. A product page can show a slightly old rate; a checkout that locks in a price might refuse it or ask the API again.

Type and as_of. A derived rate's as_of is its oldest input. If you display "rates updated at ...", use the oldest as_of in the batch, not the newest.

If you cache the batch, store as_of and status with each rate and key the cache by base. The caching guide covers expiry rules that avoid showing stale prices.

Turn a batch into prices with exact decimals

Once you have the rates, convert locally and round once, at the end. Here is a Python example using Decimal. The rates are example values, not live data:

from decimal import Decimal, ROUND_HALF_UP

# Example rates for base EUR, taken from a batch response (JSON strings).
rates = {"USD": "1.0842", "GBP": "0.8561", "CHF": "0.9410"}

price_eur = Decimal("49.99")
cent = Decimal("0.01")

for quote, rate in rates.items():
    raw = price_eur * Decimal(rate)             # 49.99 * 1.0842 = 54.199158
    shown = raw.quantize(cent, ROUND_HALF_UP)   # 54.20
    print(quote, shown)

Never pass the rate through float(). Keep the unrounded value if you need an audit trail, and round only for display or invoicing. Currencies like JPY have no minor unit, so quantize to the right number of decimals per currency. More detail is in currency conversion rounding without floating-point errors.

For a single exact amount, such as an invoice total, use GET /v1/convert?from=USD&to=EUR&amount=125.50, which returns a converted_amount and also costs 1 unit. Rule of thumb: batch rates when you are pricing many items in many currencies, convert when you need one exact figure.

Quick checklist

  • One base per call, up to 20 quotes.
  • Deduplicate and validate codes with the free catalog.
  • Chunk larger lists and run them sequentially or with a small concurrency cap.
  • Read unsupported, status and as_of for every batch.
  • Keep rates as strings or decimals; round once, at the end.
  • Cache by base and respect freshness.

Try it with your own currency list

The free plan needs no credit card, and the dashboard playground lets you paste a list of quotes and see the full response before you write any code. Create a free account, then compare plan quotas and per-second limits on the pricing page once you know how many batches your app makes per day.

All articles →
Get Multiple Exchange Rates in One API Call — GetRatesAPI