This project is a simple currency exchange API built with Spring Boot. It provides an interface for converting currency amounts between different currencies using real-time exchange rates.
mvn clean package
docker build -t currency-exchange-api .
Run the Docker container using the built image:
docker run -p 8080:8080 -p 3030:3030 currency-exchange-api
Visit http://localhost:8080/swagger-ui/index.html
in your web browser to interact with
the API using the Swagger UI.
Configuration settings can be found and modified in the application.properties
file:
api.url
: The URL of the external API for fetching exchange rates.spring.datasource.url
: The URL of the database containing API key information.spring.datasource.username
and spring.datasource.password
: Database
credentials.GET /api/currency/convert/{baseCurrency}/{targetCurrency}/{amount}
: Converts an amount from
the base currency to the target currency.Swagger UI provides a visual interface for interacting with the API. It automatically generates documentation
for the API's endpoints, including the HTTP methods, parameters, and responses. You can access it by
navigating to http://localhost:8080/swagger-ui/index.html
.
Caching is implemented using the Caffeine library. The cache is set to have an initial capacity of 100 and a maximum size of 500. Cached values expire after 1 hour of access.
The Currency Converter API requires API key authentication. To access the API, you need to include your API key in the request headers.
Authorization: Bearer <your-api-key>
For testing purposes, you can use the following public test API key:
Discontinued
Live test on EC2
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.