- The API is the kind of classes/interfaces/methods/... that you call and work to achieve an aim, and
- the SPI is the kind of classes/interfaces/methods/... that you extend and implement to achieve a goal.
Put differently, the API tells you what a specific class/organization does for you, and the SPI shows you what you must do to comply.
Usually, API and SPI are separate. For instance, in JDBC the Driver class is a portion of the SPI: If you want to practice JDBC, you don't require to use it directly, but everyone who implements a JDBC driver must implement that class.
Sometimes they project, however. The Connection interface is both SPI and API: You practice it routinely when you use a JDBC driver and it requires to be completed by the developer of the JDBC driver