Skip to main content

HTTP Call Node

The HTTP Call Node within Fleak enables users to make HTTP API calls directly from their workflows, integrating external data sources seamlessly into their Fleak transformations. This node allows you to connect to any RESTful API endpoint, pass dynamic inputs, manage authorization, and capture the response as part of your data workflow.

Http Call Node Demo Image

Configuring the URL

The URL Template field allows you to specify the endpoint you want to hit. You can hardcode the URL or use JSON path expressions to make the endpoint dynamic based on the node’s input. In the example below, the lat and lng values are dynamically replaced from the input JSON object's lat and lng field. Fleak automatically resolves the JSON paths at runtime.

Input Data:

{
"lat": 36.7201,
"lng": -4.4203
}

HTTP URL:

https://api.sunrise-sunset.org//json?lat={{$.lag}}&lng={{$.lng}}

Since sunrise-sunset is a public API, there is no need for authorization. Click 'Run Step' and the response will be displayed in the output panel:

Http Call Node Output Image

HTTP Methods

Select the HTTP method appropriate for your request, such as GET, POST, PUT, or DELETE. The most common are:

  • GET: Used to retrieve data.
  • POST: Used to send data.
  • PUT: Used to update data.
  • DELETE: Used to delete data.

Authorization

The Fleak HTTP Client Node offers flexible options for handling API authorization. It supports two types of authorization methods: Basic Authentication and Bearer Token Authentication. Both methods can be dynamically configured using JSON paths from the node's input, ensuring that API calls are both secure and adaptable to various use cases.

Basic Authentication

Basic Authentication requires a Username and Password, though some APIs may refer to them as Client ID and * Client Secret*. This method encodes the credentials and sends them with the request headers, ensuring secure communication between Fleak and the external API. This setup is ideal for APIs that require static credentials or those that need to authenticate via unique identifiers.

Example Setup:

  • Select Basic Authentication as your authorization method.

  • Input the Username and Password (or Client ID and Client Secret).

    • You can also use dynamic placeholders based on the input JSON.
    • For example, if your input contains client_id and client_secret, set the username and password fields like this:
Http Call Node Basic Auth Image
  • The node will automatically encode and include the authorization header in the API request.

Bearer Token Authentication

Bearer Token authentication is another widely-used method, particularly for OAuth-based APIs. The node allows you to pass an access token as part of the API call's authorization header. This method is particularly useful when working with OAuth APIs, where tokens expire and need to be dynamically passed with each request

Example Setup:

  • Select Bearer Token Authentication from the Authorization Type drop-down.

  • In the Token field, you can either:

    • Input a static token if it's constant, or
    • Use a dynamic token pulled from the input JSON.
    • For example, if your token is provided in the input, you can reference it like this:
Http Call Node Bearer Token Auth
Image

HTTP Headers

In many cases, API requests require more than just the Authorization header. Common headers include Content-Type, which specifies the data format of the request, or custom headers that are unique to the API you are interacting with.

To add these headers in Fleak's HTTP Client Node, follow these steps:

  • Go to the Header Templates section.
  • Click Add to create key-value pairs for each header

HTTP Body for POST and PUT Requests

When using POST or PUT methods, you may need to define a request body. This is done in the HTTP Body field. Here you can also use dynamic values from the input. Depending on your API endpoint schema, an http body can be JSON or other format. e.g.

{
"grant_type": "client_credentials"
}

or

grant_type=client_credentials

Handling HTTP Response

The response of the API call will be stored in the http_call_output field as a STRING, with original input fields attached within the same JSON. You can view it directly or use Fleak’s SQL node to cast it back to JSON for easier manipulation.

SELECT http_call_output::json FROM events;

Limitations

  • Response Format: All API responses, regardless of their original format (JSON, XML, etc.), will be cast into a string. You will need to explicitly cast it back to JSON if needed, as shown above.
  • Rate Limits: Make sure to manage your API calls in accordance with the rate limits of the external service you're calling.
  • No Built-in Error Handling: The node will return the raw API response. If the call fails, no output will be passed to the next node.