Blog How to Loop Join Multiple REST APIs: Tutorial
a

How to Loop Join Multiple REST APIs: Tutorial

How To Loop Join Multiple REST APIs: Tutorial

In this tutorial, we will learn how to use the Loop join feature to join two or more REST APIs, avoiding the repetitive and manual task of passing the parameter each time. What the loop join does for you is automate this process and save time. Loop Join can be performed between any two datasources that pass parameters. Before diving into the topic, let’s revisit some REST API basics.

What are REST APIs, and Why Join Them?

REST APIs, or Representational State Transfer Application Programming Interfaces, are rules and conventions for building and interacting with web services. They allow different software applications to communicate with each other over the internet, enabling the exchange of data and functionality.

Here’s a breakdown of what makes up a REST API:

1. Resources: In REST, everything is a resource, a physical object (like a user), or a virtual concept (like a transaction). Each resource is uniquely identified by a URI (Uniform Resource Identifier).

2. HTTP Verbs: REST APIs use standard HTTP methods (GET, POST, PUT, DELETE) to perform actions on resources. For example, GET is used to retrieve data, POST to create new data, PUT to update existing data, and DELETE to remove data.

3. Representation of Resources: REST APIs are represented in different formats, such as JSON (JavaScript Object Notation) or XML (eXtensible Markup Language), commonly used to transmit data between a client and a server.

4. Statelessness: REST APIs are stateless, meaning that each request from a client to the server must contain all the necessary information for the server to fulfill it. The server doesn’t store any client state between requests.

5. Uniform Interface: REST APIs have a uniform interface that simplifies communication between clients and servers. This includes using standard HTTP methods, resource identifiers, and representations.

Now, why join the REST APIs?

1. Interoperability: REST APIs enable interoperability between different systems and platforms. They allow diverse applications, written in various languages and running on other platforms, to communicate and share data seamlessly.

2. Scalability: RESTful architectures are highly scalable, allowing systems to handle many requests without compromising performance. This scalability is essential for modern web applications and services that need to hold a growing number of users and data.

3. Flexibility: REST APIs offer flexibility in designing and implementing web services. Developers can choose the technology stack, data formats, and communication protocols best suit their needs.

4. Time-Saving: Joining APIs saves time compared to running the APIs separately. It also saves time by automating the process.

5. Better Insights: Joining APIs provides better data insights between two connected or disconnected datasets. 

Overall, joining the world of REST APIs opens up opportunities to build scalable, interoperable, and flexible web services that can power a wide range of applications and systems.

How to Join REST APIs?

To learn to join REST APIs, here is a detailed step-by-step blog post: Joining REST APIs Tutorial.

Types of Joins

At Knowi, there are five ways to join the Datasources:

  • Inner Join
  • Left Outer Join
  • Right Outer Join
  • Full Outer Join
  • Loop Join

How to use Loop Join to Join REST APIs: A Demo

Once we have set up two different REST API sources, we can now Loop Join them with the following steps:

  1. Select the datasource for your first query. In this example, we’re choosing a REST API, specifically the Knowi management API.

  2. Add the endpoint you want to call. By default, a call is of type GET. Check the POST box if the endpoint is of type POST and add the payload in the box.

  3. In the Headers section, enter any Optional Headers, one Header per line. Example:
X-Parse-Application-Id: zjfXOr8WHrJI3GW49koxAPzT48eeWvFetM9Jkw2L
X-Parse-REST-API-Key: S2z9zkuurH00hdXq2vXz5n8Xw6LIPs6rURatTKuy
In the case of auth tokens, to pass it in on the request, use {tokenName}.

For example: Authorization: Bearer {access_token}

  1. Enter the URL parameters in the URL Params section.
  2. For any transformations on the query, enter the query in the C9QL transformations box. Refer to the documentation here.
  3. Enter pagination details, if any.
  4. You can preview the query at this stage by hitting Preview.

  5. Now, we will join this REST API with another endpoint via loop join. To do this, repeat steps from 1 to 6. Enter the appropriate endpoint you want to hit. In this example, we’re trying to hit /share.

  6. Now, configure the query for a loop join. You can use the Join builder or type it in the Join Fields box. 

Choose the join type from the Join Type dropdown. Choose the left field and right field over which the join happens. Click Save. Here’s the demo:

We have the results from the first and second queries for all the ids in the final result. Three rows in the result signify three API calls that were loop-joined.

At Knowi

For more advanced use cases in which you need to join and blend your datasources with other SQL/NoSQL/REST-API data sources, check out Knowi. This analytics platform natively integrates with REST APIs and is accessible to technical and non-technical users. You can then use the dashboard and widget features to build custom visualizations that simplify your data and make them presentable. Still trying to understand? Book a demo today with Knowi and embark on a transformative analytics journey.

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email
About the Author:

RELATED POSTS