API vs Microservices, What is the difference…?

Shanaka Sandanayaka
3 min readJun 29, 2020

--

Two of the most trending words on the internet these days. Over the years interoperability in computer systems has been evolved. With the expansion of the internet and the innovation of mobile phones apps required a convenient method to interconnect the component and work seamlessly. And also should be agile to cater to the changes. Both of these words are related to the interoperability in computer systems. But one is an architectural style while other is a framework.

To get a proper idea regarding these two, Let’s discuss the following topics.

  • What is an API?
  • What is a Microservice?
  • The Difference Between APIs and Microservices.

What is an API (Application programming interface)?

An application programming interface (API) is a computing interface which defines interactions between multiple software intermediaries.

The above is the definition of the API according to Wikipedia. As it describes, It is the doorway for application developers to communicate with the back-end components. This will decouple the caller from the underneath implementation. The caller does not have any idea regarding the technologies and the methodologies used to implement the backed.

Curtsy : https://www.aloi.io/docs/installation/

In the modern world, REST API’s are the most common form of API’s which communicate data using the HTTP protocol with JSON or XML payload. Apart from the REST, There are so many API design styles such as SOAP, gRPC, GraphQL, Websocket…etc. Specifications such as OpenAPI define the API in human-readable format.

What is a Microservice?

Simply the Microservice architecture is about splitting the big monolithic application into small manageable decoupled pieces. This will allow us to gain benefits such as increased agility, Scalability, and resiliency…etc.

Curtsy : https://dev.to/alex_barashkov/microservices-vs-monolith-architecture-4l1m

And a Microservice is a single component after splinting as above. And those components will talk to each other in order to achieve one functionality. The use of Microservices could be beneficial in many more ways. The following are some of the advantages.

  • Since the components are loosely coupled, Developers are having a small codebase to maintain for a single component.
  • The responsibility of each component is more defined. Therefore maintain and improving the component is much easier when it compares to the monolithic app.
  • Since each component could use separate technological from others, Engineers could decide the best technologies for each component by looking at its overall responsibility.
  • Each component could be scale up or down independently on demand.
  • Components could be isolate during the failures, Therefore an error or a bug in one microservice, Will be minimize the overall impact of the whole system when compared to the monolithic app.

Even though there are tons of advantages, There could be some disadvantages over all of these advantages such as.

  • High complexity in the overall design
  • The complexity of routing.
  • Require more resources …etc.

The Difference Between APIs and Microservices.

By this point, Assume you have some idea about the API’s and the Microservices. Now let’s highlight some of the key differences between these two.

  • Microservices is an architectural style dividing a large monolithic application into small fragments.
  • But API is an interface in between services and the application consumes those services.

There’s definitely an overlap between the two since so many Microservices use APIs to communicate between themselves.

--

--