Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (2.6k points)

What is the difference between Service Provider Interface (SPI) and Application Programming Interface (API)?

More specifically, for Java libraries, what makes them an API and/or SPI?

1 Answer

0 votes
by (46k points)
  • The API is the type of classes/interfaces/methods/... that you call and apply to obtain an aim, and
  • the SPI is the kind of classes/interfaces/methods/... that you reach and perform to reach an object.

Put otherwise, the API shows you what a particular class/method does for you, and the SPI shows you what you must do to conform.

Usually, API and SPI are separate. For example, in JDBC the Driver class is a portion of the SPI: If you completely want to use JDBC, you don't require to use it immediately, but everyone who completes a JDBC driver must implement that class.

Sometimes all overlap, however. The Connection interface is both SPI and API: You apply it routinely while you use a JDBC driver and it needs to be performed by the developer of the JDBC driver.

Related questions

0 votes
1 answer
asked Aug 25, 2019 in Java by Shubham (3.9k points)
0 votes
1 answer
asked Feb 25, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer
asked Feb 14, 2021 in Python by laddulakshana (16.4k points)

Browse Categories

...