A Java console application for currency conversion using the Fixer API.
Homework project for the REST Client / External API lesson at AIT TR GmbH (cohort 60).
Using the Fixer API, build a currency converter application where the user enters from the console:
- The currency to convert from
- The currency to convert to
- The amount to convert
The application prints the converted result.
- Java 23
- Spring Web (
RestTemplate,UriComponentsBuilder) β no Spring Boot - Jackson Databind (JSON deserialization)
- Lombok
- Maven
- The app prompts the user to enter input via the console
- Builds a request to
https://api.apilayer.com/fixer/convertwith query paramsfrom,to,amount - Sends an HTTP GET request with the API key in the
apikeyheader usingRestTemplate - Deserializes the JSON response into
FixerResult - Prints the converted amount and target currency
Enter currency (from): USD
Enter currency (to): EUR
Enter amount: 100
Result: 91.25 EUR
src/main/java/ait/fixer/
βββ FixerAppl.java # Main class β reads console input, calls API, prints result
βββ dto/
β βββ FixerResult.java # Maps JSON response (success, date, result, query)
βββ utils/
βββ DataFromConsole.java # Reads from, to, amount from Scanner
git clone https://github.com/AOgit/ait-fixer-api.git
cd ait-fixer-apiRun via IntelliJ IDEA or:
mvn compile exec:java -Dexec.mainClass="ait.fixer.FixerAppl"Note: The API key is hardcoded in
FixerAppl.java. To use your own key, register at apilayer.com and replace the value ofapiKey.