Building Applications with the REST API Integration

The Superblocks Team
+2

Multiple authors

January 25, 2023

5 min Read

Copied

REST, or Representational State Transfer, is a set of architectural principles for building web services. It is based on the idea that the web is a resource-based system, where each resource is identified by a unique URI (Uniform Resource Identifier), and can be accessed and manipulated using standard HTTP methods (such as GET, POST, PUT, and DELETE). RESTful services are typically built using HTTP and return data in a format such as JSON. REST is often used to build web services that are lightweight, scalable, and easy to maintain.

In this post 

Connecting to REST APIs is a fast way to build internal applications based on data from any source. This example will build out a usable application to display attraction status, live and forecasted wait times from theme parks around the world. It relies on the REST API provided by https://themeparks.wiki/ so you can build out your own version of this application. You’ll learn how to fetch data from a REST endpoint and display the results in a table, as well as build a slideout for more attraction details.

Connecting your REST API

The REST integration can be set up against both open and authenticated endpoints with Superblocks supporting a variety of authentication methods. Basic authentication, bearer token, API key, and OAuth2 support provide plenty of authentication options. Credentials can be optionally dynamically fetched via another Superblocks Workflow, and the tokens will be automatically managed by Superblocks.

For this application however, the API is openly available and so no authentication is required.

Creating an Application

Starting with a new application, the first thing to do is set up an API to load all of the destination data into the application. For this API we’ll need to target the `destination` endpoint.

Using a python step, the data can be manipulated into the `label`, `value` structure that a dropdown component requires.

With the data ready, we can add a couple of dropdowns that we can use to select the resort and the individual park. This can be done quickly with drag and drop from the components panel.

As the data for the parks is nested inside the JSON data for the resort, we need a way to populate the park dropdown based on the resort selection. State Variables can be used here to store the state of the resort dropdown, and use the stored value to filter the park dropdown.

The park dropdown above has an onOptionChange trigger set to run the live_times API.  Let’s create that now to retrieve all of the live data of the park’s attractions, this will target the `/entity/{{park_dropdown.selectedOptionValue}}/live` endpoint.

Returning to the components we can drag in a table component and set the Table Data property to the `live_times.response`. Superblocks table components automatically created all the required columns for you based on the JSON data passed to them, this is a great time saver! The columns can now be adjusted to suit you, reorder them, hide columns such as the ID column, change font and background colors based on the contents, or change the date formats.

The application is really coming together fast, to allow users to drill into a specific attraction a slideout can be added. This can be easily done from within the table properties panel by adding an `Open/Close Slideout` action to the `onRowClicked` event handler. A final API is also required to gather the live data from the selected attraction. The slideout can display the live wait time in a text component, the current local time at the park, as well as a chart of the forecasted wait times to help users plan their day.

The application is well on its way, and you can experiment with adding more details, such as an image of the attraction or implementing a connection to Google Sheets to export the data to.

Sharing applications with RBAC

The finished application can be shared quickly and easily with individuals, or groups via the Share modal for granular role-based access control. Superblocks will take care of all of the headaches of authentication and authorization for you.

Audit logging

Search the logs of every user action in your internal Applications, Workflows, and Scheduled Jobs execution history. Use Audit Logs to quickly identify errors as well as who is running queries against your data. It's a great tool for troubleshooting any API errors, especially for scheduled jobs/workflows that run during off-hours.

Workflows and Scheduled Jobs

The REST integration can be used in both Superblocks Workflows and Scheduled Jobs. Following the application in this post, one idea for a scheduled job could be to have a report posted to Slack or Email every 30 minutes with the current wait times for a specific park.

Try out the REST integration with Superblocks

Superblocks has helped hundreds of developers save 100s of hours of time both in building and in using internal applications.

To learn more about how to create internal Applications, Jobs, and Workflows with Superblocks view our documentation. Try creating your first application today with a free 14-day trial​​.

Stay tuned for updates

Get the latest Superblocks news and internal tooling market insights.

You've successfully signed up
The Superblocks Team
+2

Multiple authors

Dec 13, 2023