Sunday, August 7, 2011


What is the difference between API and SPI ? This is what we are going to explore in this blog post :-)

API stands for Application Programing Interface, where API is a mean for accessing a service / function provided by some kind of software or a platform.

SPI stands for Service Provider Interface, where SPI is way to inject, extend or alter the behavior for software or a platform.

Normally developers get mixed with the above types of interfaces and provide a cocktail of both with out understanding who are the intended actors for both and what are there use cases.

API is normally target for clients to access a service and its has the following properties:
  • API is a programmatic way of accessing a service to achieve a certain behavior or output
  • From API evolution point of view, addition is no problem at all for clients
  • But API's once utilized by clients it can not (and should not) be altered / deleted unless there are an appropriate communications, since its a complete degradation of the client expectation

SPI on the other part are targeted for providers and has the following properties: 
  • SPI is a way to extend / alter the behavior of a software or a platform (programable vs. programmatic)
  • SPI evolution is different that SPI evolution, in SPI removal is not an issue
  • Addition of SPI interfaces will cause problems and may break existing implementations

Normally splitting the two type of the API's is best practice, but some times a blur line appear about what should be an SPI and what should by an API.

This comes from the perception that API is something to call and SPI is something to implement, also to add, if you asked two people about both you may get two different answers about what they are :-)

The bottom line, think about both type of interfaces the next time you design your system or solution, since you don't want to make your end users frustrated or confused !

I would recommend reading the book Practical API Design Practical API Design: Confessions of a Java Framework Architect to get more on the subject.

Also I would recommend to view the following videos: How To Design A Good API and Why it Matters and the Paradoxes of API Design.

As always, appreciate any comments or feedback.

Thank you .


  1. An interesting one. The differentiation of API & SPI is clearly mentioned in this article & also the properties you have mentioned is also quite important for this article.
    event organizer app

  2. SPI is for service provider to provide their respective implementation for the service.
    API is for end-user to use service while being agnostic of underlying implementation details of service provider.

    For example: Driver class is SPI that various JDBC driver vendors must implement to provide JDBC connectivity to their respective databases, whereas, DriverManager class is a API that provides basic service for managing a set of JDBC drivers.