What Is an API, and How Do Developers Use Them?

You’ve likely seen the term “API” come up. Operating system, web browser, and app updates often announce new APIs for . But what is an API and how do developers utilize them?

What Is an Application Programming Interface

The term API is an acronym, and it stands for “Application Programming Interface.”

Think of an API like a menu in a restaurant. The menu provides a list of dishes you can order, along with a description of each dish. When you specify what menu items you want, the restaurant’s kitchen does the work and provides you with some finished dishes. You don’t know exactly how the restaurant prepares that food, and you don’t really need to.

Similarly, an API lists a bunch of operations that developers can use, along with a description of what they do. The developer doesn’t necessarily need to know how, for example, an operating system builds and presents a “Save As” dialog box. They just need to know that it’s available for use in their app.

Watch Explainer Video About API:

This isn’t a perfect metaphor, as developers may have to provide their own data to the API to get the results, so perhaps it’s more like a fancy restaurant where you can provide some of your own ingredients the kitchen will work with.

But it’s broadly accurate. APIs allow developers to save time by taking advantage of a platform’s implementation to do the nitty-gritty work. This helps reduce the amount of code developers need to create, and also helps create more consistency across apps for the same platform. APIs can control access to hardware and software resources.

APIs Make Life Easier for Developers

Let’s say you want to develop an app for an iPhone. Apple’s iOS operating system provides a large number of APIs as every other operating system does to make this easier on you.

If you want to embed a web browser to show one or more web pages, for example, you don’t have to program your own web browser from scratch just for your application. You use the WKWebView API to embed a WebKit (Safari) browser object in your application.

If you want to capture photos or video from the iPhone’s camera, you don’t have to write your own camera interface. You use the camera API to embed the iPhone’s built-in camera in your app. If APIs didn’t exist to make this easy, app developers would have to create their own camera software and interpret the camera hardware’s inputs. But Apple’s operating system developers have done all this hard work so the developers can just use the camera API to embed a camera, and then get on with building their app. And, when Apple improves the camera API, all the apps that rely on it will take advantage of that improvement automatically.

This applies to every platform. For example, do you want to create a dialog box on Windows? There’s an API for that. Want to support fingerprint authentication on Android? There’s an API for that, too, so you don’t have to test every different Android manufacturer’s fingerprint sensor. Developers don’t have to reinvent the wheel over and over.

APIs Control Access to Resources

APIs are also used to control access to hardware devices and software functions that an application may not necessarily have permission to use. That’s why APIs often play a big role in security.

For example, if you’ve ever visited a website and seen a message in your browser that the website is asking to see your precise location, that website is attempting to use the geolocation API in your web browser. Web browsers expose APIs like this to make it easy for web developers to access your location—they can just ask “where are you?” and the browser does the hard work of accessing GPS or nearby Wi-Fi networks to find your physical location.

However, browsers also expose this information via an API because it’s possible to control access to it. When a website wants access to your exact physical location, the only way they can get it is via the location API. And, when a website tries to use it, you the user can choose to allow or deny this request. The only way to access hardware resources like the GPS sensor is through the API, so the browser can control access to the hardware and limit what apps can do.

This same principle is used on modern mobile operating systems like iOS and Android, where mobile apps have permissions that can be enforced by controlling access to APIs. For example, if a developer tries to access the camera via the camera API, you can deny the permission request and the app has no way of accessing your device’s camera.

File systems that use permissions as they do on Windows, Mac, and Linux have those permissions enforced by the file system API. A typical application doesn’t have direct access to the raw physical hard disk. Instead, the app must access files through an API.

APIs Are Used For Communication Between Services

APIs are used for all kinds of other reasons, too. For example, if you’ve ever seen a Google Maps object embedded on a website, that website is using the Google Maps API to embed that map. Google exposes APIs like this to web developers, who can then use the APIs to plop complex objects right on their website. If APIs like this didn’t exist, developers might have to create their own maps and provide their own map data just to put a little interactive map on a website.

And, because it’s an API, Google can control access to Google Maps on third-party websites, ensuring they use it in a consistent way rather than attempting to messily embed a frame that shows the Google Maps website, for example.

This applies to many different online services. There are APIs for requesting text translation from Google Translate, or embedding Facebook comments or tweets from Twitter on a website.

The OAuth standard also defines a number of APIs that allow you to sign into a website with another service—for example, to use your Facebook, Google, or Twitter accounts to sign into a new website without creating a new user account just for that site. APIs are standard contracts that define how developers communicate with a service, and the kind of output those developers should expect to receive back.

If you’ve gotten through this, you’ll have a better idea of what an API is. Ultimately, you don’t really need to know what an API is unless you’re a developer. But, if you see a software platform or service has added new APIs for various hardware or services, it should be easier for developers to take advantage of such features.

You might also like
Leave A Reply

Your email address will not be published.