This is the second part of our series What Are APIs and How Do They Work? In part 1, we used the standard electrical socket found in most walls as a metaphor for explaining the principles of an API.
Imagine what life might be like without such a standard. For example, with no plug, matching socket or standard particulars (often called specifications), we might have to hard-wire appliances into the walls of buildings. This would involve gathering the required tools, unsheathing all the wires and splicing the wires together. Of course, we would also need to know something about the wires coming out of the wall. Moving an appliance from one location to another would be a major undertaking in disconnection and reconnection.
Luckily, we don’t have to do any of this. We have plugs and sockets that conform to a standard, which affords the following “conveniences”:
As interfaces go, APIs and the benefits they provide to their consumers (such as desktop, Web, mobile and server-side applications) are not that much different from electrical sockets and the benefits they provide to their consumers (such as computers and appliances).
For example, in much the same way a consuming device can outsource its electricity to a service through a wall socket interface, a consuming application can outsource its requirements for data (such as a patient record) or functionality (such as a location represented as a pin on an interactive map) to a service through an application programming interface. Though the consuming application and service (known as an API provider) are sufficiently decoupled to the point that they know little or nothing about one another, the interface through which they communicate represents a set of agreed-upon standards (similar to the 120v/60Hz AC standard for electricity) that enables applications to make requests of the service and get data and/or functionality in return. From one API to the next, this set of agreed-upon standards is known as the API's "contract."
And, similar to the way in which consuming devices outsource their power requirements to service providers through an electrical network, applications can outsource their requirements for data and functionality to service providers that are across digital networks, like the Internet (or even just across a local-area network at a business). For example, a mobile application for home buyers can incorporate interactive maps and navigation into its user experience by outsourcing that functionality to Google Maps. Each time that mobile application displays a new interactive map, it does so by sending a request across the Internet to a special API that’s offered by Google for that very purpose.
So, as with electricity, APIs can be consumed (to the extent that an application outsources certain requirements to an API) and provided as a service.
In addition to calling APIs from across a network, application developers can leverage APIs offered by the local system or device that their application runs on. For example, applications can discover a smartphone’s current location by calling the API associated with the phone’s GPS receiver. There’s also an emerging class of APIs offered by modern Web browsers, such as Chrome and Firefox, that are like the aforementioned standard electrical sockets--across all types of systems (desktops, tablets, smartphones, and so on), these browsers offer a standard way for browser-based applications to access the host device’s storage, audio system, cameras, and much more. From across a network, the source of data or functionality that’s called through an API could be an application server (a database server, for example), a translation service or even a network-enabled refrigerator.
This is part of our series What Are APIs and How Do They Work? In part 3, we’ll discuss the types of APIs that make the Web programmable (as in the “ProgrammableWeb”).
+You have been redirected
You have been redirected to this page because Servicetrace has been acquired by MuleSoft. Click here to learn more.
+You have been redirected
After 17 years of reporting on the API economy, ProgrammableWeb has made the decision to shut down operations.
Click here to learn more.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4