On an internet filled with confusing and unfamiliar acronyms, it can be easy to become confused. One web acronym you may have heard but never felt inspired to look into is “API”.
What is an API? API is an acronym for application programming interface, and is a name for a set of routines and protocols that make the process of building software applications much easier.
A simple way to look at an API is as a roadmap that tells the components of a piece of software how to interact. Without the use of an API, source code could look like a jumbled, confusing mess.
However, APIs are complex and require more than a brief summarization. In this article, let’s go over how APIs work and what sites and services use them.
What Is An API and How Does It Work?
Now that we have established that an API is a set of routines that point software in the right direction, how exactly does this all work?
The best way to explain the core functionality of an API is to provide a real-world example. Food delivery services, such as GrubHub, are incredibly popular right now, so let’s discuss how the code behind mobile apps like these might work.
When you search for a restaurant or item of food on one of these apps, you receive relevant results based on your keywords and location. Upon selecting a result, you’re presented with food item options, delivery times, and more restaurant-specific options.
To schedule your delivery, a connection between the delivery website and a database must occur—the website being the frontend and the database being the backend. The database is what stores the data for all of these restaurants, their availability per location, operation schedule, menus, and more.
The API is the connection between this database and the website or app that is presenting its data. It’s important that an API is present to create this connection, rather than using hard-coded data, primarily because of the popularity of third-party integrations.
For example, it would be beneficial for a website if third-party aggregators were able to list and organize all of the restaurants and items it has available, right? Without an API, this wouldn’t be possible without using inefficient web-scraping techniques.
The API is the interface responsible for delivering the data from the database to the application, be it a website, mobile app, or anything else. APIs have become the standard way of accessing and communicating application data across the web, and every major website or service that depends on third-party connectivity greatly benefits by providing one.
What Types Of APIs Are There?
There are multiple different types of API protocols, but the three most popular are SOAP (Simple Object Access Protocol), REST (Representational State Transfer), and RPC (Remote Procedure Call).
SOAP APIs
SOAP was first introduced in the late 1990s and enabled applications to share resources in a simple way through using network connections. SOAP relies on standard protocols, such as HTTP and SMTP, which enable it to be used across practically every environment due to the popularity of such protocols.
Its main strength is that it is widely used and established. If it ain’t broke, don’t fix it.
REST APIs
REST was introduced in 2000 by Roy Fielding. Its immediate goal was to act as a response to many of the issues that were created by the widespread adoption of SOAP.
Similar to SOAP, REST relies on HTTP to transfer information between applications. However, one major difference that sets it apart from SOAP, which requires data to be transmitted via the XML data format, is that it supports JSON. JSON is a data format that many agree is easier to read and write. Additionally, REST APIs can cache data, allowing for much better performance.
REST now accounts for more than 80% of all APIs, according to a 2017 report by Cloud Elements.
RPC APIs
RPC APIs come in many flavors, but as we learned from REST APIs, JSON is a very popular data format, so JSON-RPC is its most popular.
JSON-RPC is a protocol best suited for minimalists and users who rely on the straightforwardness of their API. Its much narrower in scope when compared to SOAP and REST, and it’s very limited in its flexibility and set of commands—but for some developers, less is more.
There are other RPC-based API types, such as gRPC, but JSON-RPC is the go-to if your priority is the simplicity of implementation.
Who Uses APIs?
Developers of any kind, be it frontend or backend, should have experience working with APIs. In terms of websites or web services, practically all of the major players have some sort of API available—the most obvious being Windows.
With Microsoft Windows being the most popular operating system on the planet, it’s only natural that application developers will need a set of guidelines for how to interact with its UI. Without access to the Windows API, programming an application that relies heavily on interacting with the operating system would be a major headache.
There are thousands of APIs out there, some free and some paid. Here are just a few examples worth looking into:
- Google Play Developer API: Publishing and app-management tasks related to Google PlaySkyscanner APIs: Travel-based APIs relating to flights, car hires, and moreTwilio API: Allows programmatic sending and receiving of phone callsDiscord API: Allows users to create the bots that make Discord the messaging service it is todayIPinfo API: On-the-fly IP address and geolocation data for your website or app
APIs are one of the key connectors behind some of the web’s largest and most important websites and applications. While the average user may not be able to see the benefit that APIs provide, they are a godsend to developers and web services.