Exchange Rate API: Getting TCMB and ECB Rates and Converting Amounts

An online shop that shows prices in foreign currencies, a sales team that sends quotes in euros, an app that reports in several currencies: they all need current rates from a reliable source and correct conversions. This guide covers APIKodu's currency APIs: TCMB Exchange Rates, ECB Exchange Rates and the Currency Converter that builds on both. They work with currency codes and amounts only; no personal data is involved.

Which API does what?

  • TCMB Exchange Rates returns the latest rates published by the Central Bank of the Republic of Türkiye, with forex buying/selling and banknote buying/selling in separate fields.
  • ECB Exchange Rates returns the latest rates published by the European Central Bank, with EUR as the base currency.
  • Currency Converter converts an amount using TCMB or ECB rates. The default source is TCMB and the default quote is forex selling.
  • Live Forex returns free-market rates quoted in Turkish lira, with buying, selling and change. Use it when you want a market price rather than an official rate.

Every call goes over HTTPS with an x-api-key header. Keys and quotas are covered in getting started with one API key.

Fetching TCMB rates

Pass code for a single currency, or leave it out to get them all:

curl "https://api.apikodu.com/api/v1/exchangerates/tcmb?code=USD" \
  -H "x-api-key: YOUR_API_KEY"

The response is wrapped as { data: { ... } } and contains:

  • date: the TCMB rate date. On weekends and holidays you get the previous business day's rates.
  • source: always TCMB.
  • rates[]: the list of rates, or a single item if you passed code. Each item has code, name (the Turkish currency name used by TCMB), forexBuying, forexSelling, banknoteBuying and banknoteSelling. Banknote values can be null for some currencies.

For ECB, the endpoint is /api/v1/exchangerates/ecb. It also takes an optional code, and rates are EUR-based.

Converting amounts

Often you need the converted amount rather than the rate itself. The Currency Converter does it in one call:

curl "https://api.apikodu.com/api/v1/exchangerates/convert?amount=100&from=USD&to=TRY&source=tcmb&quote=forexSelling" \
  -H "x-api-key: YOUR_API_KEY"

Parameters:

  • amount (required): an amount greater than zero.
  • from, to (required): ISO 4217 currency codes.
  • source: tcmb (default) or ecb. TCMB is TRY-based; ECB is EUR-based.
  • quote: TCMB only. forexSelling (default), forexBuying, banknoteSelling or banknoteBuying.

You can send the request as a query string or as a POST with a JSON body. The response includes result (the converted amount), rate (1 from = rate to), inverseRate, source, quote and the rate date. If from and to are the same, rate is 1.

Which quote should you use?

TCMB publishes four values per currency: forex buying, forex selling, banknote buying and banknote selling. The right one depends on your business and accounting needs. For invoicing or statutory records, agree with your accountant which rate applies. The API gives you the choice; the default is forex selling.

Handling errors

Errors come back as { code, message }. The main cases for the currency APIs:

  • 400: invalid request, for example a code not in the TCMB list (-225), a missing or non-positive amount (-278), or an invalid quote (-279).
  • 401: the API key is missing, invalid or not allowed for this API (-100).
  • 429: the per-minute request limit was exceeded (-221), or your plan credits don't cover the request.
  • 503: the rate cache is temporarily empty or rates couldn't be fetched (-224 for TCMB, -226 for ECB).

A practical tip: rates don't change every second, so cache the result briefly on your side. You'll avoid unnecessary calls and can still show the last known rate during a temporary 503. Displaying the rate date next to converted prices also keeps things transparent for your users.

FAQ

What happens if I call it on a weekend?

TCMB doesn't publish rates on weekends or holidays, so the API returns the previous business day's rates. The date field tells you which day.

TCMB, ECB or Live Forex?

Use TCMB for the official Turkish reference rate, ECB for the euro-based European reference, and Live Forex for free-market prices.

Can I use these from my AI tool?

Yes. Connect them to tools like Claude Code through our MCP server and simply ask for the latest EUR rate.

Where can I see every parameter?

Each API's parameters, sample responses and error codes are in the API Catalog and the OpenAPI 3.1 specification.

APIKodu Team

APIKodu Team

Similar Articles