Let’s all take a moment to appreciate unsung hero of connectivity

Image for post
Image for post

Introduction

Programmers are making sure that they help each other out. APIs are one of the many ways that they are proving that also. Unlike in the earlier days of Computer Programming, in nowadays programmers are not building everything from scratch. Instead, they are being capable of assembling different programs and building one single unit. APIs are the main method to do so.

What is an API

API which is also known as Application Programming Interface can be explained simply as this,

The ability to use other peoples’ code in your application.

Too Simple? let me give you a more complex definition,

API is a set of functions and procedures allowing the creation of applications that access the features or data of an operating system, application, or other service.

-from Wikipedia-

Don’t worry, I have given you these definitions only to get a grip on our topic. Instead, we are understanding about APIs through examples. In the introduction, I have defined APIs as the ability to assemble different programs. Well, Let’s look into that.

example 1:-

Image for post
Image for post

Let’s say I’m building a hotel booking app. If the user entered the location and his/her pricing, my app will show all the hotels that the user can afford. Then I must think of a way to get all the data about hotels around the world. Now, how to get the data? Do I need to travel all around the world and collect information about hotels?

Here comes APIs to the rescue. Around the world, there are many data servers out there that store information about hotels. If anyone can access and retrieve these data from these servers, it would lead to a compatibility issue. That’s why these servers offer APIs to interact with them. API is the messenger that transfers our requests and responds. Now I can get the information that I wanted in the first place, via APIs.

Features of APIs

example 2:-

Image for post
Image for post
Weather App (Preview)

The second example that I’m going to explain is a weather app. This weather app is a possibility that we have achieved through APIs.

These apps use third-party APIs to retrieve weather predictions. Through these APIs, the process of building these ‘weather apps’ became much simpler. Therefore APIs open up possibilities by not having to do everything from scratch.

example 3:-

Image for post
Image for post
Face-Detection App (Preview)

Let’s say for your new app, you want to grant user access through face detection. You will find many APIs online that will do that for you. These APIs will analyze and compare the user’s images for you. However, most APIs are not free when it comes to implementations like this. You did not have to learn the mechanism behind to add that face detection feature to your application. Here APIs were able to remove the complexity of applications.

example 4:-

Image for post
Image for post
Alerts (Preview)

Your mobile phone contains your personal data. More often than not, apps that you use day to day need to access these data. For example, you might see alert dialogs such as ‘This app needs to access your gallery’ or ‘Allow this app to access your camera’. Well, you might think that these alert dialogs were thrown by apps.

Mobile phone manufacturers install certain APIs into your phone to let you know whenever an app is granting access to your mobile phone system. Therefore every time a phone (not the app) asks for permission to access the camera, microphone, or location, you must know that the app is trying to access an API in the system. That brings up the third feature. APIs are used as gatekeepers for accessing your data.

When allowing different apps and services to exchange information, developers came up with many methods, software architectures, or protocols that these apps and services can follow. Among them, we will discuss REST APIs.

REST APIs

REST is the short term for REpresentational State Transfer. REST is an architectural style. In simple terms ‘REST APIs’ describes a set of functions that developers can perform requests and receive responses. This method follows the rules that everybody can agree on, we also have compatibility between different systems. When you are sending a request to these APIs, you can send requests in one of these four methods,

(We use the term resource to define the data that we receive)

GET — receive a resource

PUT — change state, update a resource

POST — create a resource

DELETE — remove the resource

REST APIs are used for web services. URI (Universal Resource Identifier of which URL is a specific type) is used in this method to identify senders and receivers uniquely. Simply, if you want to get data from a REST API, you must link to a specific URL. HTTP (HyperText Transfer Protocol) and JSON data format are used to exchange data.

In this medium post, we have discussed what APIs are and we have identified features of an API through examples. Also, I have given a brief definition of the most common set of APIs that developers use nowadays. (REST APIs)

Well, that’s about it for my explanation of APIs. Tune in for more medium posts just as exciting as this.

Written by

Undergraduate | Developer | https://iamsahan.web.app/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store