Docs / Rates

Convert an amount

Converts an amount between two currencies using one of the published rate sources.

GET/v1/rates/convert
import { Client } from "@liveapiio/liveapi";

const client = new Client({ token: process.env.LIVEAPI_TOKEN });

const conversion = await client.convert({ from: "USD", to: "TRY", amount: 100, source: "tcmb" });

Request

Send Authorization: Bearer YOUR_TOKEN. The token stays on your server. Each library reads it from the environment and calls this endpoint for you.

FieldTypeDescription
fromstringSource currency code. Required.
tostringTarget currency code. Required.
amountnumberAmount to convert. Optional.
sourcestringecb, fed, or tcmb. Optional.
datestringCalendar day, YYYY-MM-DD. Optional.
tcmb_ratestringforex_buying, forex_selling, banknote_buying, or banknote_selling. Used with the TCMB source.

Response

A 200 response uses one call. Returns the two currencies, the amount, and the rate that was applied.

Errors

A failed request returns { "error": { "code", "message" } } and does not use a call.

StatusCodeWhen
400invalid_requestA required field is missing or has the wrong type.
503upstream_unavailableThe rate source is unavailable.
401unauthorizedThe bearer token is missing or not recognized.

We value your privacy

We use necessary cookies to run this website. With your consent, we would also like to use analytics and marketing cookies. Read our cookie policy.