API vs SPI

What is difference between API and SPI?

API defines interface that a client should use to perform a task

SPI defines interface that a service provider must implement to perform a task.

E.g. JDBC (Statement, Connection Interfaces are SPI which must be implemented by Database driver). However, Log4J is an API as it provides set of interfaces to use logging.

JNDI architecture is perfect example, where JNDI provides API to be used by cleint (us) and also a set of SPI that service provider must implement to provide the underlying services.

The following link provides more details on this. I too have added an answer here (read that and vote up :) )

http://stackoverflow.com/questions/2954372/difference-between-spi-and-api