Skip to content

Add my FastAPI currency exchange project #29

This project is a currency exchange API built with FastAPI, made to create product and possibility to show in converted in other currencies and manually set course of currency

###Technologies Used

-FastAPI(uvicorn for the server part)

-SQLite

-Pytest

Functionality:

  • Store and update rates in a local SQLite database.
  • List all stored historical exchange rates.
  • Update rates manually using a script.
  • Full suite of unit tests for endpoints and logic.

API Endpoints

Products

GET /products Get all products

GET /products/{id} Get a product by ID

POST /products Add a new productJSON Body:

{ "name": "iPhone 15", "price": 999.99, "currency": "USD" }

Currency Conversion

GET /convert?id={product_id}&to_currency={currency} Convert a product's price to another currency

Currency Management

GET /currencies Get all available currency rates

POST /admin/update-rate?code={CURRENCY}&rate_to_usd={RATE} Update or add a currency rate (admin-only)

History

GET /conversion-history Get past conversions (for audit/logging)

Admin CLI Tool

Run the standalone script to manage currencies manually:

python3 admin_script.py

Options:

Show all currencies, Update a currency rate and Exit.

Running Tests

Run Test:

pytest test_api.py

Tests include: Adding and retrieving products, Handling non-existing products, Currency conversion

C Rittgerm

Edited by rittgerm

Merge request reports