Русский | English | Español | 中文 | Français | Deutsch |
---|---|---|---|---|---|
Русский | Selected | Español | 中文 | Français | Deutsch |
Currency Converter is a project for working with the currency exchange API. You can request exchange rates, perform conversions, and test functionality through ready-made tests.
currency-converter/
├── docs/... # Materials used in README.md
├── src/
│ ├── main.py # The main file for launching the application
│ ├── api_service.py # Working with the API (requests and processing)
├── tests/
│ ├── test.py # Tests to check the functionality
├── index.py # The entry point for launching the application
├── .env # Configuration file (token and URL). It is created independently!
├── .env.example # Example of a configuration file
├── .gitignore # Ignored Git files
├── requirements.txt # List of dependencies
├── README.md # Project documentation
Clone the project to your local computer:
git clone https://github.com/yaleksandr89/freecurrencyapi-converter-python.git
cd freecurrencyapi-converter-python
It is recommended to use a virtual environment to isolate dependencies:
# Creating a virtual environment
python3 -m venv venv
# Virtual Environment activation
source venv/bin/activate # For Bash/Zsh/Linux/macOS
venv\Scripts\activate # For Windows
Install dependencies from requirements.txt
:
pip install -r requirements.txt
- Rename the
.env.example
file to.env
:
mv .env.example .env
- Specify the token and the base API URL in
.env
:
API_TOKEN='ВАШ_API_ТОКЕН'
API_URL='https://api.freecurrencyapi.com/v1'
Run the project through the file index.py
:
python3 index.py
To run the tests, use the file tests/test.py
:
python3 tests/test.py
This file checks the correctness of the API connection and displays a list of available currencies.
Successful conversion
Conversion error
A PHP project has been created with similar functionality, but with a number of differences:
- Implemented a web interface
- All available service endpoints are described.
Code example: freecurrencyapi-converter-php — Everyone's there, come in! 😄
-
Security Token:
- Make sure that your API token is specified correctly in
.env
. - Never add the
.env
file to the repository.
- Make sure that your API token is specified correctly in
-
Recommendations:
- Use a virtual environment to isolate dependencies.
- Update dependencies if necessary via
pip install --upgrade
.