Home > Blockchain >  Do API contain only interfaces? Can't it contain classes also?
Do API contain only interfaces? Can't it contain classes also?

Time:04-14

I am new to API(Application Programming Interfaces). I want to ask whether API is a subset of Interfaces. Can API contain classes? Also I came to know that APIs are used to build functionalities for carrying out say a communication between two layers. This functionality building is explicitly through interfaces only or any class is also used?

CodePudding user response:

Your API is the set of public things exposed to users of your code, and the contracts they guarantee and document. It includes public classes, public constructors, public methods, public interfaces (and all interface methods, since they are definitionally public), public enums, public fields, etc.

Since classes can be public, they can be part of your API.

(I think you're significantly overcomplicating the concept of an API for yourself.)

  • Related