What is an Application Programming Interface (API)?

An application programming interface (API) is a specification to be used as an interface by software components to communicate with each other. Specifications for routines, data structures, object classes, variables, may include. An API specification can also take other forms such as vendor documentation. This would include MS Windows API. Other forms might be programming language libraries, for instance, the standard Template Library in C++, or Java API.

Language Used

An API may be:

  • Language dependent. In other words, it may be available by using the syntax and elements of a specific language;
  • Language independent. Conversely, written in a way that it may be extracted from several programming languages. A specific-oriented API that is not bound to a specific process or system has this as a desirable feature. This API may be provided as remote procedure calls or web services. For instance, a website is able to layer customers’ reviews over maps taken from Google Maps, as the latter has an API that facilitates this functionality. Google Maps’ API decides what information a third-party site can use and how they may use it.

A complete interface, a single function, or even an organization’s set of APIs, defines API.

The context of usage determines the scope of meaning.

API in object-oriented languages

In object-oriented languages, a description of an asset of class definitions, with a set of behaviors associated with those classes, is an API. The classes that are implemented in terms of class methods expose the real functionality associated with this abstract concept.

Defining API

The totality of all the methods publicly exposed by the classes is the API. The API dictates the methods by which one interacts with/handles the objects derived from the class definitions.

It may be possible to understand the API as the collection of all the kinds of objects one can extract from the class definitions and their associated possible behaviors. Caveat: public methods mediate this use. However, in this interpretation, the methods you can see as a technical detail of the manner of behavior implementation.

For example, a stack class may simply expose publicly two methods – push, and pop. While to push signifies the addition of a new item to a stack, pop indicates the extraction of the last item, ideally put on top of the stack.

API construed & explained

The API has two methods pop and push. Conversely, it may construct as the idea that one may use an item of type stack that implements the behavior of the stack. That is simply the picture of a pile exposing its top to add/remove elements.

The logical termination of this is the point at which an API class interface has no methods at all. It has only behaviors associated with it. For example, the Java language and Lisp have serializable API. The latter is a marker interface that requires each class implementing it to behave in a serialized manner. The requirement here is that any class that implements it has a representation that can save at any time.

Hence, in object-oriented languages, the API determines a set of object behaviors. This determination is possibly a mediator with a set of class methods.

API Libraries & Frameworks

A software library has easy relation to an API. The API details and determines the expected behavior. On the other hand, the library is an actual implementation of this set of rules. Multiple implementations may accrue to an API. This may take the form of different libraries that share the same programming interface.