Get All Exchange Rates
curl http://localhost:8080/api/ExchangeRate
Retrieves all exchange rates configured in the system.
Response
Array of exchange rate objects Unique identifier for the exchange rate
The target currency object (same structure as baseCurrency)
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
GET /api/ExchangeRate/{searchString}
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
Search term to find exchange rates (searches in currency codes)
Response
Array of matching exchange rate objects
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
Currency code for the base currency (must exist in the system)
Currency code for the target currency (must exist in the system)
Exchange rate from base to target currency (must be a valid positive number)
Example Request
{
"baseCurrencyCode" : "USD" ,
"targetCurrencyCode" : "EUR" ,
"rate" : 0.92
}
Response
The created exchange rate object Generated unique identifier
Full base currency object
Full target currency object
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
PATCH /api/ExchangeRate/{baseCurrencyCode}&{targetCurrencyCode}
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
Currency code for the base currency
Currency code for the target currency
Request Body
New exchange rate value (must be a valid positive number)
Example Request
Response
The updated exchange rate object 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" ]
}
}