FXConvert is a currency conversion API built using FastAPI. It provides real-time currency exchange rates and powerful conversion features to support various applications, including e-commerce platforms, financial dashboards, and budgeting tools.
- 💱 Real-time currency conversion.
- 🌐 Support for multiple currencies.
- 🛠️ Lightweight and easy to integrate.
/src
├── /api
│ └── currency_routes.py # Endpoints for currency conversion
├── /models
│ └── currency_model.py # Pydantic models for request validation
├── /services
│ └── exchange_service.py # Core logic for currency conversions
├── /utils
│ └── helpers.py # Utility functions
├── main.py # FastAPI app initialization
└── requirements.txt # Project dependencies
-
Clone the repository:
git clone https://github.com/DevAnseSenior/fx-convert.git cd fx-convert
-
Create a virtual environment and activate it:
python -m venv .venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Get a personal Alpha Vantage API key. In the website, follow the tutorial to obtain the personal key;
-
Create a .env file in the project root with the same template as .env.example and add your Alpha Vantage personal key in the indicated variable;
-
Install the required dependencies:
pip install -r requirements.txt
-
Start the FastAPI server:
uvicorn main:app --reload
-
Access the API documentation:
- Interactive API docs (Swagger UI):
http://127.0.0.1:8000/docs
- Alternative API docs (ReDoc):
http://127.0.0.1:8000/redoc
- Interactive API docs (Swagger UI):
Method | Endpoint | Description |
---|---|---|
GET | /converter/{from_currency} |
Convert currency amount synchronously |
GET | /converter/async/{from_currency} |
Convert currency amount asynchronously w/ query parameters |
GET | /converter/async/v2/{from_currency} |
Convert currency amount asynchronously w/ body parameters |
http://127.0.0.1:8000/converter/BRL?to_currencies=USD,GBP,EUR,JPY&value=5.61
[
0.952017,
0.7607160000000001,
0.9043320000000001,
148.13205000000002
]
http://127.0.0.1:8000/converter/async/BRL?to_currencies=USD,GBP,EUR,JPY&value=5.91
[
{
"USD": 1.0023360000000001
},
{
"GBP": 0.8008050000000001
},
{
"EUR": 0.952101
},
{
"JPY": 155.95899
}
]
http://127.0.0.1:8000/converter/async/v2/BRL
{
"value": 5.90,
"to_currencies": [
"USD",
"GBP",
"EUR",
"JPY"
]
}
{
"message": "success",
"data": [
{
"USD": 1.00005
},
{
"GBP": 0.7994500000000001
},
{
"EUR": 0.9504900000000001
},
{
"JPY": 155.64790000000002
}
]
}
- E-commerce platforms: Display real-time prices in different currencies.
- Finance apps: Offer currency tracking and conversion tools for users.
- Data analysis: Integrate exchange rate data for market research.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to reach out with questions or suggestions:
- GitHub: DevAnseSenior