The realtime API family
Tags: api, devops, serverless, productivity
Published: 2019-12-10 10:09:06

Looking to 2020 and beyond, the proportion of data produced and consumed in realtime is growing exponentially. [IDC predict](https://www.zdnet.com/article/by-2025-nearly-30-percent-of-data-generated-will-be-real-time-idc-says/) that by 2025 1/3 of all data produced globally will be realtime. The engineers and organizations that make up the realtime ecosystem, Ably included, have yet to agree on how we describe the APIs we’re creating and consuming that are powering this growth. The problem is that there are various ways to describe APIs that provide realtime functionality.

API evangelist [Kin Lane](https://twitter.com/kinlane/), and many others, have been [writing](http://real-time.apievangelist.com/) and talking about these new types of APIs for a while. Event-driven seems to be the most common descriptor. Gartner has adopted the term, stating that [by 2020 50% of all managed APIs will be event-driven](https://www.gartner.com/en/documents/3660318). But still today there is no consistency or consensus between what terms like realtime API, event-driven API, or streaming API refer to. Often they’re used interchangeably.

As an engineering team and API provider working on a global pub/sub messaging platform, we work with these ideas everyday. Talking to our users we see the language they use to describe both what we do and what they achieve using our APIs. And we’ve watched discussions around event-driven architecture, webhooks, and streaming data proliferate.

Over the years we’ve thought extensively about the best terminology to use and arrived at what we call the Realtime API Family.

**The Realtime API Family**
![The Realtime API Family](https://ik.imagekit.io/ably/ghost/prod/2019/12/realtime-api-famils.png?tr=w-1520)

1. Defining realtime
2. Streaming APIs
3. Pub/Sub APIs
4. Push APIs
5. Event-Driven APIs

**Defining realtime**
As a concept, realtime is easy enough to understand: a function or interaction perceived as immediate. Ably defines it as anything that happens in under 100ms. Any API designed such that data flowing from producers to consumers happens in the shortest amount of time possible can therefore be described as realtime.

Ably has settled on realtime API as an umbrella for event-driven, streaming, pub/sub, push, and other APIs. We’ve seen many more than four ways of describing this, but these are the most popular. It’s why we call it the Realtime API Family.

**Streaming APIs**
A stream is a means of transporting data. Streaming is a consumer pattern that describes how consumers receive events through a stream.

A streaming API will commonly address issues of data integrity with:

- [Message ordering](https://support.ably.io/solution/articles/3000044641) - ensure messages are delivered in the order they were published
- [Stream continuity / resume](https://www.ably.io/blog/10-hardest-aspects-of-realtime-messaging) - upon disconnection, resume from the disconnected point within a set period of time
- [Contiguous serial numbers](https://www.ably.io/documentation/client-lib-development-guide/protocol#message-acknowledgement) - a simple series of `ACK` or `NACK` responses, each addressing a contiguous sequence of messages

Kafka offers a [streaming API](https://kafka.apache.org/documentation/#api) following this model for internal systems.

**Pub/Sub APIs**
Pub/Sub (Publisher/Subscriber) is an infamous messaging design pattern. When it debuted in 1987 it solved loose decoupling of servers. The earliest distributed systems used to send events between servers using Pub/Sub, but all within reliable networks. This pattern operates by publishing messages on a topic (or [channel](https://www.ably.io/channels)) within a message bus, and subscribers can listen for events based on those topics.

![Ably's Pub/Sub Channels API acts as a serverless message bus](https://ik.imagekit.io/ably/ghost/prod/2019/12/diagram-channels-landscape@3x.png?tr=w-1520)

Pub/Sub is over 30 years old now. The design makes no attempt to define semantics around ordering or continuity (loss of connection). While it’s still a pattern used widely today, these are issues that must be [considered](https://www.ably.io/blog/10-hardest-aspects-of-realtime-messaging/) and [addressed](https://www.ably.io/blog/message-queues-the-right-way/) in our world of unreliable connections.

Ably provides a [pub/sub API](https://www.ably.io/channels) following this model but with guarantees around ordering, continuity, idempotency, and more.

**Push APIs**
![Ably's unified push notifications API](https://ik.imagekit.io/ably/ghost/prod/2019/12/ably-native-push-notifications-1200x630.jpg?tr=w-1520)

Push is another umbrella term for every API that is real time. But it's just a producer messaging pattern. It means that data is pushed upstream over a connection, versus a pull mechanism used by the request/response pattern.

An example is helpful. A [push notifications API](https://www.ably.io/push-notifications) is an example of a push API. Or a [sporting event](https://www.ably.io/case-studies/tennis-australia) might send a single score update that traverses multiple systems via push APIs, resulting in millions of messages to global fans within a few hundred milliseconds.

Push can also refer to triggering a new request as with a [Webhook](https://www.ably.io/documentation/general/webhooks). Or it can mean ‘push subscription’ - i.e. a producer needs to reach out to a consumer. WebSub is an example of this. But that’s a whole other blog post.

**Event-driven APIs**
Event-driven is an architectural design pattern that defines how a system processes data. It simply states a system should be responding/[reacting](https://www.ably.io/reactor) to events as they happen. Streaming, Pub/Sub, and Push are all messaging patterns that can delivered through an event-driven architecture. As such they can all fall under the umbrella of event-driven APIs.

Most of us know what an event-driven API is but an example never hurts. Unlike traditional request/response APIs where data is requested, event-driven APIs push data from a producer to a consumer. They can be quite simple or very complex.

![An event-driven retail experience](https://ik.imagekit.io/ably/ghost/prod/2019/12/event-driven-flow-ably.png?tr=w-1520)

In the above example a retailer needs an event-driven architecture to respond to things as they happen. An event in an event-driven world triggers a chain of events which must be processed downstream, extending through the entire data supply chain. All components in this supply chain are reactive, rapidly responding to events and performing onwards processing.

The time-bound, reactive nature of this data supply chain causes increased engineering and infrastructure complexity. And when compared to REST APIs following the request/response model, the complexity is inverted and put onto API producers rather than API consumers.

![The inversed complexity of REST and event-driven APIs](https://ik.imagekit.io/ably/ghost/prod/2019/12/event-driven-complexity-ably.png?tr=w-1520)

However, that’s a conversation beyond the scope of this article. But it’s something we’ve spoken about before at [API World](https://apiworld.co/) 2019: [Taming the rising complexity of event-driven APIs](https://speakerdeck.com/mattheworiordan/taming-the-rising-complexity-of-event-driven-apis).

**And so we arrive at Realtime APIs**
Streaming, Pub/Sub, and Push are all patterns that can be delivered through event-driven architecture. But the outcomes of streaming, push, pub/sub, and event-driven are all realtime functionality. They’re all means of getting data from producer to subscriber in the shortest possible time. So we can call them realtime APIs.

But you can’t have a realtime API unless it’s delivered as an event-driven, pub/sub, streaming, or push API. Hence how we’ve settled on the umbrella term of realtime API to encompass them all.

**Navigating complexity and fragmentation**
As you can see, it’s easy to use these terms interchangeably despite them all being different. The realtime ecosystem is still maturing and changes all the time. Eventually we believe developers and organizations will naturally come to a shared and standardized terminology for APIs designed to deliver real time functionality.

Until then, the Realtime API Family helps us to reduce complexity when we explain our [cloud infrastructure](https://www.ably.io/network) and [APIs](https://www.ably.io/solutions/realtime-apis) to the developer community, our users, and our potential customers.


***About Ably***
Ably provides cloud infrastructure and APIs to help developers  simplify complex realtime engineering. Organizations build with Ably  because we make it easy to [power and scale realtime features in apps](https://www.ably.io/solutions/realtime-apis), or [distribute  data streams to third-party developers](https://www.ably.io/solutions/api-management) as realtime APIs. We support [multiple open protocols](https://www.ably.io/adapters) and a growing number of [third-party integrations](https://www.ably.io/reactor). Take a look at [what our customers say](https://www.ably.io/showcase) about us and our realtime APIs :).

***About the author***
Kieran Kilbride-Singh: Writer + marketer with enough technical know-how to be dangerous in GitHub repos. He's been writing about tech for five years, first flexing his fingers on topics like interoperability in IoT devices.