Exchange API
The next step is to create an API that allows users to convert between currencies. The API must use a third-party service to fetch exchange rates. Note that this microservice must be implemented in Python.
flowchart LR
subgraph api [Trusted Layer]
gateway --> account
gateway --> auth
account --> db@{ shape: cyl, label: "Database" }
auth --> account
gateway e1@==> exchange:::red
gateway --> product
gateway --> order
product --> db
order --> db
order --> product
end
exchange e3@==> 3partyapi:::green@{label: "3rd-party API"}
internet e2@==>|request| gateway
e1@{ animate: true }
e2@{ animate: true }
e3@{ animate: true }
classDef red fill:#fcc
classDef green fill:#cfc
click product "#product-api" "Product API" Attention
To consume the API, the user must be authenticated.
Using FastAPI1 (or another framework) on Python , create a REST API that allows users to convert between currencies. The API should expose the following endpoint:
GET /exchanges/{from}/{to}
Get the current exchange rate from one currency to another. E.g. GET /exchange/USD/EUR.
The API should rely on a third-party service to fetch exchange rates. You can use the free tier of any of the following, e.g.:
- AwesomeAPI;
- ExchangeRate-API;
- Open Exchange Rates;
- CurrencyLayer;
- any other API.
Or, you can scrape the data from a website.
Hint
You can use the requests library to make HTTP requests to the third-party API.