Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.9k 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 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

Related questions

0 votes
1 answer
asked Aug 15, 2019 in Java by Krishna (2.6k 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

...