Member-only story

API vs. Messaging — How to Choose Which One to Use?

Mario Bittencourt
Better Programming
Published in
7 min readJun 13, 2023
Photo by Tim Gouw on Unsplash

We have been living in a distributed world for quite some time, and when considering how should you implement the communication between any two parties involved, the discussion seems to gravitate around two options: API or messaging.

Instead of focusing on the lost battle of which one is better, how about we focus instead on looking at their characteristics, what heuristics can we use to help our decision, and ultimately the consequences of choosing one?

Let’s begin by looking at APIs, which seem to be the predominant choice — or at least the first one considered.

Application Programming Interface

APIs define the contract that allows two applications to communicate with each other. This contract is in the form of protocols and styles that the server is committed to providing and that the client should adhere to.

A predominant style found today is REST, having replaced SOAP in this service-oriented architecture that is commonplace nowadays. While it has limitations it is often considered a natural fit for our HTTP culture.

A worthy mention, albeit if being more specific is the Remote Procedure Call (RPC). It is a protocol that enables a client to call a function — a procedure — on a remote server as if it was…

Responses (3)

What are your thoughts?