What is the real difference between an API and an microservice?

fm433403 picture fm433403 · Aug 13, 2017 · Viewed 25.4k times · Source

I am learning about microservices and I don't understand what the real difference between creating a REST API and creating microservices?
I’m working in Go, but my question applies over all languages.

Answer

Lior Bar-On picture Lior Bar-On · Aug 13, 2017

The Microservices approach is about breaking your system ("pile of code") into many small services, each typically has its own:

  • Clear business-related responsibility
  • Running process
  • Database
  • Code version control (e.g. git) repository
  • API (the protocol how other services / clients will contact the Microservice)
  • UI

The services themselves are kept small so as your system grow, there are more services - rather than larger services.

Microservices can use REST, RPC, or any other method to communicate with one another, so REST or an API is really orthogonal to the topic of microservices...

Reference: What is an API? In English, please.