What is an API?

Node in Stack AI

If you are not familiar with the concept, an API stands for Application Programming Interface and is a set of rules and protocols that allows different software entities to communicate with each other. APIs define the methods and data formats that applications can use to request and exchange information

How to use it?

Connections to an API node

You can use an API Node to load information to your workflow from a specific application (yours or from a third-party).

To use it, you will need to specify some parameters:

  • Method: choose between GET and POST. GET is primarily used to retrieve information from the server / application. POST is used to submit data to the server for processing or storage.
  • Params: choose between Body and Query. If you select Body, data is sent in the request body, separate from the URL, while if you select Query data is appended to the URL after a ? character.
  • URL: endpoint or webaddress where the API is accessible.
  • Headers: specify the authentication token and some other required parameters. Headers help define the operating parameters of an HTTP transaction (i.e., to call the API).

Additionally, you will need to connect the API node to an input and output:

  • Input : Only required if you are chose Body as parameter. Use an Input Node to especify the body.
  • Output : Connect the API node to an Output Node, an LLM (be mindful of the context window), or a Vector Database (if response is very lengthy)

Example of usage

In this simple example, we are calling another Stack AI workflow via its API endpoint to get its output.

Triggering another Stack AI workflow and processing the results

We utilize an LLM (i.e., OpenAI GPT 3.5 Turbo) to refine and process the results obtained from the API call.