Skip to main content

Get All Exchange Rates

curl http://localhost:8080/api/ExchangeRate
Retrieves all exchange rates configured in the system.

Response

exchangeRates
array
Array of exchange rate objects
id
integer
Unique identifier for the exchange rate
baseCurrency
object
The base currency object
id
integer
Currency ID
code
string
Currency code
fullName
string
Full currency name
sign
string
Currency symbol
targetCurrency
object
The target currency object (same structure as baseCurrency)
rate
float
Exchange rate from base to target currency

Example Response

[
  {
    "id": 1,
    "baseCurrency": {
      "id": 1,
      "code": "USD",
      "fullName": "United States Dollar",
      "sign": "$"
    },
    "targetCurrency": {
      "id": 2,
      "code": "EUR",
      "fullName": "Euro",
      "sign": "€"
    },
    "rate": 0.92
  },
  {
    "id": 2,
    "baseCurrency": {
      "id": 1,
      "code": "USD",
      "fullName": "United States Dollar",
      "sign": "$"
    },
    "targetCurrency": {
      "id": 3,
      "code": "GBP",
      "fullName": "British Pound Sterling",
      "sign": "£"
    },
    "rate": 0.79
  }
]

Find Exchange Rate

curl http://localhost:8080/api/ExchangeRate/USD
Searches for exchange rates matching the provided search string. The search matches against currency codes in both base and target currencies.

Path Parameters

searchString
string
required
Search term to find exchange rates (searches in currency codes)

Response

exchangeRates
array
Array of matching exchange rate objects
id
integer
Unique identifier
baseCurrency
object
Base currency object
targetCurrency
object
Target currency object
rate
float
Exchange rate value

Example Response

[
  {
    "id": 1,
    "baseCurrency": {
      "id": 1,
      "code": "USD",
      "fullName": "United States Dollar",
      "sign": "$"
    },
    "targetCurrency": {
      "id": 2,
      "code": "EUR",
      "fullName": "Euro",
      "sign": "€"
    },
    "rate": 0.92
  }
]

Create Exchange Rate

curl -X POST http://localhost:8080/api/ExchangeRate \
  -H "Content-Type: application/json" \
  -d '{
    "baseCurrencyCode": "USD",
    "targetCurrencyCode": "EUR",
    "rate": 0.92
  }'
Creates a new exchange rate between two currencies.

Request Body

baseCurrencyCode
string
required
Currency code for the base currency (must exist in the system)
targetCurrencyCode
string
required
Currency code for the target currency (must exist in the system)
rate
float
required
Exchange rate from base to target currency (must be a valid positive number)

Example Request

{
  "baseCurrencyCode": "USD",
  "targetCurrencyCode": "EUR",
  "rate": 0.92
}

Response

exchangeRate
object
The created exchange rate object
id
integer
Generated unique identifier
baseCurrency
object
Full base currency object
targetCurrency
object
Full target currency object
rate
float
Exchange rate value

Example Response

{
  "id": 3,
  "baseCurrency": {
    "id": 1,
    "code": "USD",
    "fullName": "United States Dollar",
    "sign": "$"
  },
  "targetCurrency": {
    "id": 2,
    "code": "EUR",
    "fullName": "Euro",
    "sign": "€"
  },
  "rate": 0.92
}

Error Responses

Currency not found:
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "errors": {
    "message": ["Не удалось найти валюту"]
  }
}
Invalid rate value:
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "errors": {
    "message": ["Rate validation error"]
  }
}

Update Exchange Rate

curl -X PATCH "http://localhost:8080/api/ExchangeRate/USD&EUR" \
  -H "Content-Type: application/json" \
  -d '{
    "rate": 0.95
  }'
Updates the exchange rate for an existing currency pair.

Path Parameters

baseCurrencyCode
string
required
Currency code for the base currency
targetCurrencyCode
string
required
Currency code for the target currency

Request Body

rate
float
required
New exchange rate value (must be a valid positive number)

Example Request

{
  "rate": 0.95
}

Response

exchangeRate
object
The updated exchange rate object
id
integer
Exchange rate ID
baseCurrency
object
Base currency object
targetCurrency
object
Target currency object
rate
float
Updated exchange rate value

Example Response

{
  "id": 1,
  "baseCurrency": {
    "id": 1,
    "code": "USD",
    "fullName": "United States Dollar",
    "sign": "$"
  },
  "targetCurrency": {
    "id": 2,
    "code": "EUR",
    "fullName": "Euro",
    "sign": "€"
  },
  "rate": 0.95
}

Error Responses

Currency not found:
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "errors": {
    "message": ["Не удалось найти валюту"]
  }
}
Invalid rate value:
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "errors": {
    "message": ["Rate validation error"]
  }
}

Build docs developers (and LLMs) love