API

Rohan Rao
4 min readFeb 23, 2022

What is an API?

Have you ever wondered how it is possible to buy an item with a couple of clicks? or Make a reservation for dinner from an app? or Browse through the available list of flights to get you from point A to point B?
Well, the unsung hero here is an API! An API or an Application Programming Interface is an intermediate interface that allows two applications to talk to each other.

A very cliche example would be :- You walk into a pizza joint, ask the service representative for the pizza you want. The service representative then lets the Cook know about the order. The cook prepares the pizza and the representative brings you the pizza. You don’t know who the cook is or how he/she prepares it. You are just concerned with what you want.

An API, in the same ways lets you use a platform or a service without you having to worry about the underlying logic.
e.g. — Google Maps, Evernote etc.

How does an API works?

API, sometimes, are thought of as contracts containing some documentation about agreement between two parties. If party1 needs to use certain services that Party2 provides then it needs to structure the request in certain way. Similarly, Party2 should structure the service in certain way so that it is usable by Party1, both parties shouldn’t misuse the data provided by each other, etc.
Say, when you’re building an application for a company and your need to write certain code a service, but the service is already implemented by another company. In this case you wouldn’t want to re-build the wheel, rather you can use the service provided by the other company. In this scenario, the other company exposes an Endpoint (An endpoint is a simple URL to an API through which you can access it) to its service and you have to make a request to the service and use it in your application.

This is beneficial in two ways :-
1. Abstraction :- The API provides a layer of abstraction and doesn’t have to explain how it does the stuff.
2. Privacy and Authentication :- Whenever you want to use an API provided by a provider, you need to authorize yourself first by signing on their website/application. Upon successful authorization, you’ll be provided with a secret key that you need to pass every time you make a request. This helps in getting you authenticated as well as save data from getting exposed to unauthorized users.

Types of APIs

1.Public API :- It is an API which can be used by anyone.
2.Private API :- It is a hidden API which can only be used by certain applications internally.
3.Web API :- Superset of Public and Private API. Web API are generally hosted on a server and can be used by making a HTTP request.

API Standards :-

Different APIs can follow different formats. But some of the well defined standards for building an APIs are :-

  1. SOAP :- SOAP or Simple Object Access Protocol is a well established industry standard in which XML format is used to transfer data. These are driven by functionality rather than data.
  2. REST :- REST or Representational State Object is another well defined standard wherein an API must adhere to certain architectural constraints like Client-Server Architecture, Statelessness, Caching, Layered System etc. It supports multiple formats for transferring data like XML, JSON, YAML, plaint text etc.
  3. RPC :- An RPC is a Remote Procedural Call protocol. They’re the simplest and oldest type of API that was developed for client to execute code on the server.

Why do we need APIs?

Well, softwares need to change overtime. Gone are the days where adding any change into an existing software meant taking down the whole applications and deploying the new code. Now, whenever we need to make updates into the software we can take down the concerned piece of code without downing the entire system.
Another advantage of an API is that if there is any company which already has a certain service provided that we need, then we can use their service (with their permission) without having to write the code for the service ourselves.
Also this means that whenever an API is at fault, this doesn’t result in failure of the entire system.

Conclusion

APIs are an integral part of software development, which make the entire process more understandable, less complex and more efficient. It also helps businesses and developers to collaborate with each other and build certain exciting services.

--

--