You are here

You are here

Why Async APIs Are the Key to the Future of IoT

Rory Blundell CEO, Gravitee
Photo by Alessio Lin on Unsplash

The Internet of Things is nothing new. IoT devices have been around for decades, and they're being deployed today for a wide variety of use casesfrom connected cars and thermostats to smart traffic lights and crop management on farms.

Some use cases remain difficult to address with IoT devices, however. The problem is not with the devices themselves, but rather with the way that consumers are able to access the data produced by these devices. IoT devices often generate vast amounts of real-time data and use streaming technology to persist this data. This is not always well suited to making data available to the end user, because the IoT devices themselves lack an efficient, secure means of exposing their data to users who want to view or analyze it.

Fortunately, this is changing. With the advent of event-native APIs and API gateways, it is possible to expose data from IoT devices (and a variety of other resources) both synchronously and asynchronously, depending on the needs of data consumers.

Here's why that's a big deal and why asynchronous data streams will open up the door to a whole new range of IoT use cases.

Synchronous vs. Asynchronous Data Streams and APIs

To understand the complexity of exposing IoT data to a demanding consumer base, it is helpful to understand the differences between synchronous and asynchronous APIs.

A synchronous API is one that exposes data via a request-response model. In other words, a data consumer asks for data, and the API responds with the data. This approach is fine when data changes only periodically and/or when data consumers don't require a continuously updated stream of information.

For example, if you want to build an application that reports the outdoor temperature, a synchronous API will get the job done well enough—because the outdoor temperature doesn't change very rapidly. Updating temperature data via synchronous data pulls that happen just once an hour or so would be sufficient.

But what if you have a use case where data constantly changes, such as the volume of water flowing through a pipeline or the location of a robot on a factory floor? That's where asynchronous APIs come in.

Streaming data usually originates within back-end systems (using data-streaming tools such as Kafka or RabbitMQ). Typically, natively exposing the data from these streams can get complicated, implicating data-handling challenges such as security concerns and traffic shaping.

For instance, because these streams are not usually intended for external access, engineers must find a way to ensure that only authorized users can view the data. This can be hard, because the streaming protocols themselves don't provide access-control frameworks designed for this purpose.

Additionally, these protocols are intended for streaming data internally, where network bandwidth and latency limitations are typically much less problematic than they are on the Internet. They are not designed to optimize traffic flowing over external networks.

With an asynchronous API, however, streaming data can be exposed via APIs. That way, data consumers can access a continuously updated data stream using API calls—without the need to connect to back-end data streams directly.

Synchronous and Asynchronous APIs for IoT

IoT devices often rely on APIs to share data with the applications that need to monitor, collect, or analyze that data. Therefore, the differences between synchronous and asynchronous APIs are important in the IoT context.

If your APIs are capable only of exposing synchronous data via a traditional request-response model, then the applications relying on the IoT-produced data may have to settle for information that is not as complete or up to date as it would ideally be.

With asynchronous APIs, however, a variety of novel use cases for the IoT come within reach. When your IoT devices can continuously stream data, and when you have the ability to expose that data via asynchronous APIs in a controlled and secure manner, a whole new world of end-user applications becomes available. Asynchronous APIs make it possible to deploy IoT devices for use cases where synchronous APIs aren't enough on their own to meet the needs of data consumers.

Asynchronous IoT Use Cases: Two Examples

Take, for example, a network of IoT sensors responsible for monitoring race cars as they move around a track. Being able to expose a continuous data stream that reports the location and velocity of every car on the track is much more valuable than pulling that data synchronously on a periodic basis. With an asynchronous API, you can continuously track which cars are ahead—which is a lot better than knowing only which car was winning a minute ago (because that's the last time you performed a synchronous data pull).

Or consider a business that uses IoT sensors to monitor the flow of natural gas within a pipeline. The ability to detect sudden volume or pressure changes in real time is critical for identifying potential problems before they turn into hazards. You can't detect issues in real time if your sensors rely on synchronous APIs that report data only once every few minutes. But with an asynchronous API that provides streaming data, you can identify problems instantly.

Event-Native API Gateways: The Best of Both Worlds

The above is not to say that asynchronous APIs are always better than synchronous APIs for IoT. In many cases, it's necessary to be able to support both models at the same time. Some data consumers may only need to request data periodically, while others require access to data streams.

Supporting these use cases is possible with the help of an event-native API gateway. Event-native API gateways expose back-end data streams as APIs securely. At the same time, they can expose data synchronously if desired. Data consumers enjoy the flexibility of accessing information in whichever format they need. At the same time, developers avoid the hassle of having to maintain multiple APIs—because the API gateway handles the hard work of exposing data in multiple ways.

IoT is great, but it stands to become even better by taking advantage of event-native API gateways that can expose data streams via asynchronous APIs. Asynchronous APIs make it possible to deploy IoT devices for use cases where synchronous APIs aren't enough on their own to meet the needs of data consumers.

Keep learning

Read more articles about: Enterprise ITIT Ops