Skip to content

LeivSuaxy/pytoque

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyToque Class

Class with methods to make requests to the ElToque API (Cuba).

Installation

pip install pytoque

How to use

First you will need to request a personal token from the ElToque site.

Explanation

https://eltoque.com/eltoque-abre-acceso-a-su-api-de-las-tasas-de-cambio

Form to obtain token

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

Linux

source .venv/bin/activate

Windows

.venv\Scripts\activate

Install Dependencies

pip install -r requirements.txt

Import 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)

Docs

get_today() -> dict

Returns the exchange rates for the current date.

Additional Params

  • filters: List of strings with exchange rate abbreviations

Available filters: ['ECU', 'TRX', 'USDT_TRC20', 'BTC', 'BNB', 'USD', 'MLC']

Exceptions

  • 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

get_date(date: str) -> dict

Date parameter in format (YYYY-MM-DD)

Returns the exchange rates of the given date.

Additional Params

  • filters: List of strings with exchange rate abbreviations

Available filters: ['ECU', 'TRX', 'USDT_TRC20', 'BTC', 'BNB', 'USD', 'MLC']

Exceptions

  • 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

About

Small library to get currency costs from Eltoque

Topics

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages