Skip to main content

Endpoint

GET /api/convert/{from_currency}/{to_currency}/{amount}
Converts a specified amount from one currency to another using the current exchange rate. The endpoint returns the converted amount along with the exchange rate and timestamp.

Path parameters

from_currency
string
required
Source currency code (e.g., USD, EUR, GBP). Must be 3-5 characters in length.
to_currency
string
required
Target currency code (e.g., USD, EUR, GBP). Must be 3-5 characters in length.
amount
decimal
required
Amount to convert. Must be greater than 0 with up to 2 decimal places.

Example request

curl -X GET "http://localhost:8000/api/convert/USD/EUR/100.00"

Response

from_currency
string
Source currency code
to_currency
string
Target currency code
original_amount
decimal
Original amount requested
converted_amount
decimal
Converted amount
exchange_rate
decimal
Exchange rate used for conversion
timestamp
datetime
When the rate was fetched
source
string
Providers of rates

Example response

{
  "from_currency": "USD",
  "to_currency": "EUR",
  "original_amount": 100.00,
  "converted_amount": 85.50,
  "exchange_rate": 0.8550,
  "timestamp": "2025-09-27T10:30:00Z",
  "source": "averaged"
}

Status codes

  • 200 - Successful conversion
  • 400 - Invalid currency code (currency not supported)
  • 422 - Invalid parameters (e.g., negative amount, invalid format)
  • 500 - Internal server error
  • 503 - Exchange rate service unavailable (all providers failed)

Build docs developers (and LLMs) love