Giter Site home page Giter Site logo

currency-exchange-api's Introduction

Currency Exchange API

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

Features

  1. Currency Conversion: Converts an amount from a base currency to a target currency.
  2. Caching: Uses Caffeine cache to improve performance for frequently requested exchange rates.
  3. Rate Limiting: Limits the number of requests a client can make to the API within a certain period.
  4. API Documentation: Provides a Swagger UI for easy interaction with the API and visualizes the API's resources.

Getting Started

Prerequisites

  • Java 17
  • Docker

Building the Application

  1. Clone the repository to your local machine.
  2. Navigate to the directory containing the project.
  3. Run the following command to build the project and package it into a JAR file:
    mvn clean package

Building the Docker Image

  1. After building the JAR file, build the Docker image using the provided Dockerfile:
    docker build -t currency-exchange-api .

Running the Docker Container

  1. Run the Docker container using the built image:

    docker run -p 8080:8080 -p 3030:3030 currency-exchange-api
  2. Visit http://localhost:8080/swagger-ui/index.html in your web browser to interact with the API using the Swagger UI.

Configuration

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.
  • Rate Limiting: API rate limiting is managed through the database. You can configure rate limits for each API key in the database.

API Endpoints

  • GET /api/currency/convert/{baseCurrency}/{targetCurrency}/{amount}: Converts an amount from the base currency to the target currency.

Swagger UI

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

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.

Authentication

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

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

License: MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.