🔗 What is an API
In the world of programming and computing, you may often hear the term (API) What is this technology, and why was it created in programming? The term (API) stands for “Application Programming Interface.”
In the world of programming and computing, you may often hear the term API. What is this technology, and why was it created in programming? The term API stands for “Application Programming Interface.” Think of it like a menu in a restaurant that lists the dishes you can order, along with a description of each dish. When you select items from this menu, the kitchen prepares and serves the dishes. You don’t know exactly how the food is prepared, nor do you need to.
Similarly, an API provides a set of operations that developers can use, along with a description of what they do. Developers don’t need to know how an operating system, for example, creates and presents a “Save As” dialog box; they only need to know that it is available for use in their application.
This is not a perfect analogy, as developers might need to provide their own data to the API to get results. It’s somewhat like a high-end restaurant where you provide some ingredients that the kitchen will work with.
APIs allow developers to save time by leveraging platform-provided implementations to perform specific tasks, helping reduce the amount of code developers need to write and also promoting consistency across applications for the same platform. APIs can also control access to hardware and software resources.
Thus, an API can be defined as a description of software components based on their functions, inputs, and outputs. Its main goal is to provide a list of functions independent of the implementation mechanism, allowing others to interact with it through any other mechanism.
API Uses
Suppose an entity develops a certain system, whether a website, operating system, or Android application (e.g., a software system) and then releases it to the market. This system, naturally, offers a specific service. When this entity provides APIs, it means that it allows developers to use some of its system’s services to build their own programs.
Here are some examples for further clarification:
Example 1
Facebook provides APIs that allow fetching user data such as name, photo, age, etc. If you are developing a site with a registration component, instead of creating a form where users fill out many fields, you can use Facebook APIs to easily retrieve user data, saving time and effort. Many sites use this.
Example 2
If you are building a program with a mapping component, Google Maps offers APIs that you can use to build your own system by leveraging Google Maps.
Example 3
APIs make developers' lives easier. Suppose you want to develop an application for an iPhone. The iOS operating system from Apple provides a large number of APIs, as does every other operating system, to facilitate the process. For example, if you want to include a web browser to display one or more web pages, you don’t need to code a web browser from scratch for your app; you can use the WKWebView API
to embed a WebKit Safari browser in your app.
If you want to capture photos or videos from the iPhone camera, you don’t need to write your own camera interface. You use the camera API to integrate the built-in camera into your app. Without APIs to make this easy, app developers would have to create their own camera program and interpret camera inputs. However, Apple’s OS developers have done this hard work so that developers can use the camera API to embed a camera and start building their app. When Apple updates the camera API, all apps relying on it automatically benefit from the improvement.
This applies to every operating system. For example, if you want to create a dialog box on Windows, there is an API for that. If you want fingerprint authentication support on Android, there is also an API for that, so developers don’t need to test every fingerprint sensor for different Android products.
Controlling Access to Resources via API
APIs are also used to control access to devices and software functions that the application might not necessarily have permission to use. For this reason, APIs play a significant role in security.
For example, if you visit a website and see a message in your browser asking for your precise location, that website is attempting to use the geolocation API in your web browser. Web browsers provide APIs like this to make it easy for web developers to access your location. They can simply ask, “Where are you?” and the browser does the work to access GPS or nearby Wi-Fi networks to find your actual location.
However, browsers also expose this information via API because it is possible to control access to it. When a website wants to access your exact location, the only way to get it is through the geolocation API, and when a website attempts to use it, you—the user—can choose to allow or deny the request. The only way to access hardware resources like GPS sensors is through an API, so the browser can control access to devices and determine what applications can do.
This same principle applies to modern mobile operating systems like iOS and Android, where mobile apps have permissions that can be enforced through access control APIs. For example, if a developer attempts to access the camera via the camera API, you can refuse the permission request, and the app has no way to access your device’s camera.
File systems using permissions—like those in Windows, Mac, and Linux—have permissions enforced by the file system API. The typical application does not have direct access to the physical hard drive. Instead, the application must access files through the API.
APIs for Communication Between Different Services
APIs are used to communicate between services. For example, if you have seen Google Maps embedded on a website, that site is using Google Maps API to include that map. Google provides APIs like this to web developers, who can then use these APIs on their websites. Without such APIs, developers would have to create their own maps and provide their own map data just to display a small interactive map on the site.
Because it is an API, Google can control access to Google Maps on third-party websites and ensure it is used consistently rather than trying to embed an iframe displaying the Google Maps website, for example.
This applies to many different online services. There are APIs for requesting text translations from Google Translate, embedding comments on Facebook, or tweets from Twitter on a website.
Types of API
-
Language-specific APIs: These are available only in a specific programming language. They consist of a set of commands and functions in the same language format compiled into a particular code, all falling under a fixed name or structure that can be used by writing a single line of code without needing to worry about internal commands and functions. (As explained in Example 3).
-
Language-independent APIs: These are written in a way that allows them to be used in various programming languages. For example, a website displaying restaurant locations allows users to add extra information on the same map fetched from Google Maps, due to the fact that Google Maps API supports this functionality. Google Maps API controls what information users can utilize and how they can use it, and it’s not limited to Google Maps but used in various other tasks like integrating with a website for purchasing through Visa.
Lastly, APIs are not restricted to websites alone; programming libraries also provide APIs that allow programmers to use them. For example, an image processing library allows a programmer to call a function to resize an image within the code.
Now you have a better idea of what an API (Application Programming Interface) is. Ultimately, you don’t need to know what an API is unless you are a developer. However, if you see a platform or service that has added new APIs for various devices or services, it should be easier for developers to take advantage of these features.