Class with methods to make requests to the ElToque API (Cuba).
pip install pytoqueFirst you will need to request a personal token from the ElToque site.
https://eltoque.com/eltoque-abre-acceso-a-su-api-de-las-tasas-de-cambio
https://tasas-token.eltoque.com/
Open your virtual environment and install dependencies
Create Virtual Environment
python -m venv .venv If you use Linux remember to use python3
Activate Virtual Environment
source .venv/bin/activate.venv\Scripts\activateInstall Dependencies
pip install -r requirements.txtImport the PyToque class and initialize it by sending the api_key obtained on the official ElToque site as a parameter.
Warning Remember to be careful with the privacy of your personal token.
from pytoque.pytoque.core import PyToque
toque = PyToque(api_key=API_KEY)Returns the exchange rates for the current date.
- filters: List of strings with exchange rate abbreviations
Available filters: ['ECU', 'TRX', 'USDT_TRC20', 'BTC', 'BNB', 'USD', 'MLC']
- Exception('Incorrect Filters') If filters are not available
- Exception(f'The response was not satisfactory, HTTP STATUS: {response.status_code}') In case the API returns another status code, check the eltoque api documentation to see more.
- RequestException() In case a failure occurs in the request
Date parameter in format (YYYY-MM-DD)
Returns the exchange rates of the given date.
- filters: List of strings with exchange rate abbreviations
Available filters: ['ECU', 'TRX', 'USDT_TRC20', 'BTC', 'BNB', 'USD', 'MLC']
- Exception('Incorrect Filters') If filters are not available
- Exception(f'The response was not satisfactory, HTTP STATUS: {response.status_code}') In case the API returns another status code, check the eltoque api documentation to see more.
- RequestException() In case a failure occurs in the request
- Exception('Please provide a date in format "YYYY-MM-DD"') In case a bad date format is sent