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.
App is no longer maintained as it is personal project to fullfill my joy of being able to use EC2/S3/RDS
- Currency Conversion: Converts an amount from a base currency to a target currency.
- Caching: Uses Caffeine cache to improve performance for frequently requested exchange rates.
- Rate Limiting: Limits the number of requests a client can make to the API within a certain period.
- API Documentation: Provides a Swagger UI for easy interaction with the API and visualizes the API's resources.
- Java 17
- Docker
- Clone the repository to your local machine.
- Navigate to the directory containing the project.
- Run the following command to build the project and package it into a JAR file:
mvn clean package
- After building the JAR file, build the Docker image using the provided Dockerfile:
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
andspring.datasource.password
: Database credentials.- Rate Limiting: API rate limiting is managed through the database. You can configure rate limits for each API key in the database.
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.