The difference between an API and SOA

apisoa

There are a lot of What is the difference between... questions out there but I couldn't find this one.

Wikipedia says this about an API

An application programming interface (API) is a source code-based specification intended to be used as an interface by software components to communicate with each other.

And this about SOA

SOA also generally provides a way for consumers of services, such as web-based applications, to be aware of available SOA-based services.

Aren't both technologies where you present services to other services?
Could someone expand on this?

Best Solution

Service Oriented Architecture is an architectural methodology. It is a way of specifying separation of responsibility from a business oriented point of view into independent services, which communicate by a common API (often but not necessarily by publishing events to a bus).

As an example, you could have one service responsible for capturing customer orders, which publishes an OrderCaptured event to the bus; and a separate service responsible for tracking when the customer is billed and how much is owed, which subscribes to the Bus and responds to the OrderCaptured event. The first service might not need to know anything about billing due to the separation of responsibility. And the two services don't need to know about each other either, only about the events going on around them.

An API is an interface that a component/service exposes so that other components can communicate with it. In the example above the Bus is providing a common API for a number of services to communicate.

In summary:

API = any way of communicating exposed by a software component.

SOA = a set of enterprise architectural design principles to solve scalability issues by splitting responsibility into services.

Related Question