Skip to content

Interactions

An Interaction is the most important element in the cyhole library because it is in charge to perform all the requests to an external API system. As a conseguence, every external API implemented in cyhole has its own dedicated class that inherits from cyhole.core.interaction.Interaction class.

The structure of a standard Interaction is described by the image below:

Structure Overview
Image created using Excalidraw

Inside an Interaction there are two attributes identifying the clients responsable to perform the API calls:

By looking to the image above, it is possibile to notice that the Interaction class has also a set of private methods, one for each implemented endpoint. All these methods are then also available in client and async_client to be used.

The idea beyond this architecture is to minimise the code repetition, every endopoint is identified by a private method inside Interaction class, and this method has all the required logic to hendle the dedicated API endopint call. In addition, the method can be executed in sync or async mode; for this reason the clients inside the interaction have implemented the corresponding method in non-private mode to be executed with the desired logic.

Example

Consider the Jupiter interaction and its GET endpoint Price.

The main class inherits from Interaction class and it has:

The GET "Price" endopint is available as: