Skip to content

Api Handler

Flynn, Conor edited this page Feb 15, 2023 · 8 revisions

Introduction

The Api Handler is a subset of the DeFi Data Engine with the goal of retrieving data from external sources in an easy and code-less way. In this section we will cover how to set it up, how to extract the data it produces, and how to write properties files. Please note this page covers installation on Windows 10 so you may need to modify the instructions based on your OS.

System Requirements

To use the Api Handler you need the following:

Quickstart

Step 1

Start Docker Desktop, such that Docker can be used via the command line.

Step 2

We will now build the Docker Volume that the Api Handler will write the data to. This can be done through the following command:

$ docker volume create defi-data

If you navigate to Docker Desktop and go to the Volumes tab, it should now look like this: image

Step 3

Clone the repo to the desired directory. Note the repo is: https://github.rpi.edu/DataINCITE/IDEA-DeFi-CRAFT.

Step 4

Navigate to the root directory of the cloned repository, such that your directory is .../IDEA-DeFi-CRAFT/. From here, navigate to the Api-Handler folder by doing:

$ cd DeFi-Data-Engine
$ cd Api-Handler

Step 5

Once in the root directory of the Api Handler, we can now build the Docker container. To do this we run the following command

$ docker build -t api-handler .
$ docker run -p 8080:8080 -it -v defi-data:/data api-handler

Step 6

The Docker container should now be running and should look similar to below: image

Step 7

To terminate the application, you can go to Docker Desktop -> Containers and then stop the active container.

Accessing Data

To access data go to Docker Desktop. Once there, go to the Volumes tab and then select defi-data assuming you followed all the prior steps correctly. Once selected, go to the Data tab at the top and you will see a list of all .csv files generated. It should look similar to below: image

Note that one .csv will be generated per call, having the name of the call used. This file will be overridden should another call be made with the same name.

Properties Files

Properties files are how the Api Handler interprets new REST API calls. These files can be found in the requests directory: .../IDEA-DeFi-CRAFT/DeFi-Data-Engine/Api-Handler/src/main/resources/requests/. The template.properties folder serves as the README.txt for how these files should be formatted however that information is also reflected in this section. We will be using amberdata.io as an example for all of these parameters.

Properties

request.name

This property is the unique naming of the REST API call. This MUST be unique otherwise the application will alert you of an error. It can be named anything so long as it follows standard conventions.

url.base

This is the base url required to make the REST API call. This is typically found on the documentation of the data source. For