Follow TV Tropes


Media Notes / Application Programming Interface

Go To

"The wonderful thing about standards is that there are so many of them to choose from."
The UNIX-HATERS Handbook

An API, or Application Programming Interface, is a communication protocol between two sets of code. It's like a language; both parties agree that words have a particular meaning, so that they can talk to each other.

Why? Because Software is Hard.

Hardware makers do their best not to agree on how hardware should be made. Power requirements and connections have to be standardized, but how do you think they could actually make such a great XYZ5000 if they actually told you how they did it?

Originally - especially when a new computer comes out - people wrote code to talk directly to the hardware. MS-DOS games routinely wrote directly into the video memory for fastest results. When you start having multiple programs running simultaneously, they all can't do that, any more than everyone at a meeting can all talk simultaneously, so eventually APIs and driver programs would do the work, and programs would call them in order to play nice with everyone else. This lack of standards meant that there were times that games would refuse to run on certain PCs, depending on their configuration. Many DOS game manuals in the '80s and '90s would devote considerable space to troubleshooting advice, which often meant a lot of tedious editing of configuration files.

A driver implements a particular API that the operating system requires for interfacing with a certain kind of hardware. So hardware makers write 'software drivers' that allow your lowly computer to understand & communicate with the awesomeness that is their XYZ5000, at least on a basic level.

So your computer can now handle the hardware, be it Microsoft Windows, macOS, or UNIX.

However, Microsoft, Apple, or the various makers of the various *nixes are not stupid; they know there's malicious (or just poorly written) code out there. They are not just going to let any old program talk to drivers. Especially drivers relating to drawing stuff on the screen. The OS needs to know about this sort of thing, and it needs to manage access to that hardware.

So the OS exposes an API that allows other programs to talk to the hardware.

Application Programming Interfaces can also refer to the way a developer can make his software talk to another pre-existing piece of code, most commonly preexisting shared libraries. Shared libraries allows a developer to save time because instead of trying to reinvent the wheel, he/she could just invoke the code of another piece of software that does what he/she desires to perform the needed magic on the data, saving time. However, while all libraries have an API, whether the documentation exists or not and the library's licensing can play a role on whether it can be freely reused on another piece of software.

Alternative Title(s): API, Direct X, Open GL