Last updated 2023-02-11 06:55:47

What Is An Asynchronous (Async) API?

The most popular form of API is the synchronous API. This type of API typically relies on the HTTP protocol [↗] which is a unidirectional communication channel.

This is the kind of communication where a client or a server sends a request to another server and waits for a response. In this mode of communication, the second server can only send information to the requester or client only if they ask for it.

Asynchronous APIs on the other hand adopt an open communication model, this is where a channel is created and kept open so the client and server can send over information whenever they want or need to. An example of this will be websockets [↗].

Truth be told this channel doesn't have to stay open as long as either entity can start one when needed, a good example is webhooks [↗]. This is very similar to the use of phones where anyone can ring up the other.

What are async APIs good for?

Asynchronous APIs are very useful in situations where open communication needs to be in place. For example in chat apps using WebSockets.

Another good use of this is when one app provides a URL to a third-party service to send information over when it needs to using webhooks. For example, payment confirmation by payment gateways [→].

Here is another article you might like 😊 "What the heck is GraphQL"