Code Monkey home page Code Monkey logo

currency-conversion's Introduction

Currency Exchange API

This is a API built with FastAPI and SQLAlchemy for managing currency exchange rates.

Features

  • Update Exchange Rates: Endpoint to fetch the latest exchange rates from an external API and update the database.
  • Last Update: Endpoint to retrieve the timestamp of the last update of exchange rates in the database.
  • Currency Conversion: Endpoint to convert an amount from one currency to another based on the latest exchange rates.

Endpoints

Update Exchange Rates

  • URL: /update_rates
  • Method: GET
  • Description: Fetches the latest exchange rates from an external API and updates the database.
  • Response: Returns a JSON message indicating the success of the update.

Last Update

  • URL: /last_update
  • Method: GET
  • Description: Retrieves the timestamp of the last update of exchange rates in the database.
  • Response: Returns a JSON object containing the timestamp of the last update.

Currency Conversion

  • URL: /convert
  • Method: POST
  • Description: Converts an amount from one currency to another based on the latest exchange rates.
  • Request Body:
    • source_currency: The currency code of the source currency.
    • target_currency: The currency code of the target currency.
    • amount: The amount to convert.
  • Response: Returns a JSON object containing the converted amount.

Setup

  1. Clone the repository.
  2. Navigate to the project directory.
  3. Build the Docker containers using docker-compose -f docker-compose.yml up --build -d.
  4. Once the containers are running, the API will be accessible at http://localhost:8000.

Dependencies

  • FastAPI: Web framework for building APIs with Python.
  • SQLAlchemy: SQL toolkit and Object-Relational Mapping (ORM) for Python.
  • httpx: Asynchronous HTTP client for making requests to external APIs.
  • pydantic: Data validation and settings management using Python type annotations.
  • PostgreSQL: Database management system for storing currency exchange data.

Environment Variables

  • DATABASE_URL: Connection URL for the PostgreSQL database.

Usage

  1. Use the /update_rates endpoint to fetch and update the latest exchange rates.
  2. Convert currency using the /convert endpoint by providing the source currency, target currency, and amount.
  3. Retrieve the timestamp of the last update using the /last_update endpoint.

Contacts

telegram - @tim31560

currency-conversion's People

Contributors

anac0n6a avatar

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.